在 dev 中使用 haml、formtastic、rails 3.1.3、ruby 1.9.2、sqlite3,在生产中使用 postgres。
我有一个表单,它成功地将字符串编码为 utf-8。诸如Słów
在参数中正确传递的字符串,并在开发和生产中都很好地写入数据库。
但是,保存后,表单域显示乱码Słów
。通过类似的方式将属性放在同一页面上@work.field
也会显示乱码。
如果我调用@work.field
另一个模板文件,它会很好地呈现。
我已经做了通常的:
- Make sure 'config.encoding = "utf-8"' is there in application.rb file.
- Putting '# encoding: utf-8' on top of file containing utf-8 characters.
- Above '<App Name>::Application.initialize!' line in environment.rb file, add following two lines:
Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8