charlotte-ruby / impressionist

Rails Plugin that tracks impressions and page views
MIT License
1.54k stars 311 forks source link

Issue with utf8 param passed via Rails form helpers #249

Closed cantunes closed 7 years ago

cantunes commented 7 years ago

Rails version: 4.2.3 Ruby version: 2.3.3 MySQL version: 5.6.24

Using the impression(@model) syntax. mysql insert fails with the following message: ActiveRecord::StatementInvalid (Mysql2::Error: Incorrect string value: '\xE2\x9C\x93"\x0Ap...' for column 'params' at row 1

I can work around this by setting the enforce_utf8 option to false in the form helper in the view. Obviously not ideal.

cantunes commented 7 years ago

It turns out this is only an issue if the default char set for the mysql database is latin1 rather than utf8. Updating the following mysql settings solved this issue. Closing.

collation_server=utf8_unicode_ci 
character_set_server=utf8