开发者

ActiveRecord::StatementInvalid: Mysql::Error: Incorrect string value: '\xE2\x98\xBA.\x0D\x0A...'

I use rails 2.3.11 and on my prod machine I got this exception. In my dev machine It worked fine, Bascially Iam submitting a textarea with huge content and the column 'message' in my db is of type text, so typicaly there shouldn't be any trouble.

ActiveRecord::StatementInvalid: Mysql::Error: Incorrect string value:
'\xE2\x98\xBA.\x0D\x0A...' for column 'message' at row 1: INSERT INTO开发者_开发百科 `table_xyz


I've seen this happen (too many times) when one of the databases/tables is correctly configured to use utf8, and the other is using a different charset/collation, like latin. When the utf8 database was populated, it was done by copying over the data from the latin database. Subsequent updates/entries into the utf8 database would fail, when the data contained unicode characters, like ☃. It may be that, even without data copying, an incorrect database charset/collation could cause this. It can also sometimes help to ensure that your database yml contains encoding: utf8.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜