2012年2月28日火曜日

ERROR "incompatible character encodings: UTF-8 and ASCII-8BIT"

Rails 3.0 → 3.2 へソースを移行後に下のエラーメッセージが表示された。

ActionView::Template::Error (incompatible character encodings: UTF-8 and ASCII-8BIT):

対応

- Make sure 'config.encoding = "utf-8"' is there in application.rb file.
- Make sure you are using 'mysql2' gem
- Putting '# encoding: utf-8' on top of file containing utf-8 characters.
- Above '::Application.initialize!' line in environment.rb file, add following two lines:

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

参考サイト

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

0 件のコメント:

コメントを投稿