Rails Json response encoding
I've a rails controller that respond_to JSON with a wrong encoding. The site is correctly setup with UTF-8 encoding and the database as well. The text in my db is well formatted, but in the JSON response, all special characters are set to \ufffd.开发者_C百科 How can I solve the problem?
Everyone running on Ruby 1.9.x and using MySQL, should use the mysql2 gem. It forces the use of UTF-8 and converts to/from UTF-8 automatically when needed.
精彩评论