0

在 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
4

1 回答 1

1

哦。我在 layouts/application.rb 中添加了这个,它可以工作。

<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
于 2012-05-09T09:44:06.207 回答