2

I am using find_or_create_by method to seed a MySQL database like that:

Translation.where(:locale => 'en', :key => 'A0000', :value => 'a').first_or_create

I am using Translation class from i18n library for a purpose.

And corresponding MySQL table is like that:

id: int(11)
locale: varchar(255)
key: varchar(255)
value: varchar(255)

All has character set 'utf8' with collation 'utf8_unicode_ci'.

However, after I run bundle exec rake db:seed, I see garbage values in the "value" like:

'--- a\n...\n'
'--- b\n...\n'

On the MySQL workbench, \n's are not appearing like '\n', I just see garbage values, but I can see \n's on the log file.

I am guessing that because of these characters find_or_create_by method is not working also, it always create new rows in the database.

What could be the problem in here?

Melih
  • 666
  • 1
  • 9
  • 24

0 Answers0