Ruby on Rails 3, incompatible character encodings: UTF-8 and ASCII-8BIT with i18n

后端 未结 5 1392
再見小時候
再見小時候 2020-12-02 10:36

I\'ve got some troubles with the couple Rails 3.0.1, Ruby 1.9.2 and my website localization.

The problem is quite simple, i\'ve got something like that in a view :

5条回答
  •  我在风中等你
    2020-12-02 11:07

    Ok so problem solved after some hours of googling...

    There was actually two bugs in my code. The first one was a file encoding error and the second was the problem with the MySQL Data base configuration.

    First, to solve the error caused by MySQL I used this two articles :

    http://www.dotkam.com/2008/09/14/configure-rails-and-mysql-to-support-utf-8/

    http://www.rorra.com.ar/2010/07/30/rails-3-mysql-and-utf-8/

    Second, to solve the file encoding problem I added these 2 lines in my config/environment.rb

    Encoding.default_external = Encoding::UTF_8
    Encoding.default_internal = Encoding::UTF_8
    

    Hopefully this will help someone :)

提交回复
热议问题