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

后端 未结 5 1382
再見小時候
再見小時候 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:20

    I solved most of the problems by combining many solutions:

    • Make sure application.rb has this line: config.encoding = "utf-8".
    • Make sure you are using 'mysql2' gem
    • Putting # encoding: utf-8 at the top of any file containing utf-8 characters.
    • Add the following two lines above the ::Application.initialize! line in environment.rb:

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

    http://rorguide.blogspot.com/2011/06/incompatible-character-encodings-ascii.html

提交回复
热议问题