N
N
Nodar2015-05-13 12:12:52
MySQL
Nodar, 2015-05-13 12:12:52

How to solve problem with Rails 4, Mysql encoding?

Help me understand, Rails 4.1.6 stack, using mysql2 gem.
Added 2 fields to the existing table, name, email.
Result SHOW FULL COLUMNS FROM feedbacks;
name | varchar(255) | utf8_general_ci |
email | varchar(255) | utf8_general_ci
The name if it is specified in Russian letters is transformed into - %D0%9D%D0%BE%D0%B4%D0%B0%D1%80%D0%B8 similar.
The same table has a field of type text, which has the same encoding. It normally preserves Russian letters.
Logs from rails:
Parameters: {"{\"user_id\":\"1\",\"name\":\"ABV\",\"email\":\"[email protected]\",\ "answer\":\"5\",\"comment\":\"zuvcuv\"}"=>nil}
SQL (23.3ms) INSERT INTO "feedbacks" ("answer", "code", "comment", "created_at", "email", "name", "updated_at", "user_id") VALUES ($1, $2, $3 , $4, $5, $6, $7, $8) RETURNING "id"
I don't really want to demolish the database and restore it (as I read, it can save).
Is there a simple solution to this problem?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
E
Evgeny Lebedev, 2015-05-13
@HollowJ

Did you try to add data with Cyrillic characters directly to the database?
If not, and the data is inserted correctly, then the problem is not in the database, but in the fact that the rails do Cyrillic conversion for this property.
I’m almost not familiar with rails, well, I’ve worked with MySQL enough, I can say with almost certainty that the problem is not in the database, since the database does not recode (except perhaps the driver itself).

N
Nodar, 2015-05-13
@Nodar

Encoding is written in database.yml

K
Kirill Penzin, 2015-05-13
@kir_vesp

Perhaps you need to fix the default encoding in the settings on the server at the muscle itself to the usual utf-8, then everything should work (yesterday there was a similar problem, it was decided by changing the base encoding).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question