【发布时间】:2012-01-05 13:04:45
【问题描述】:
我对 Rails 很陌生。
我有一个现有的 MS SQL 数据库并在其上构建 rails-app。我只是从现有表中搭建了所有需要的东西。
但是,我的 index.html.erb 源代码中有一个变音符号。
<td><%= wohnung.Grösse %></td>
但这会引发 500 内部服务器错误。
development.log 对我没有帮助...:
Started GET "/wohnungs" for 127.0.0.1 at 2012-01-05 13:52:24 +0100
Processing by WohnungsController#index as HTML
[1m[36mWohnung Load (0.0ms)[0m [1mEXEC sp_executesql N'SELECT [Wohnung].* FROM [Wohnung]'[0m
Rendered wohnungs/index.html.erb within layouts/application (15.6ms)
Completed 500 Internal Server Error in 62ms
如果我删除此行,它会起作用。但是文本中的所有其他变音符号都由“�”表示......
我做了什么:
- 在 wohnung_controller 顶部添加了“#coding:utf-8”
- 在 database.yml 中添加了“编码:utf8”,
- 在 application.rb 中添加了 'config.encoding = "utf-8"',
- 向 application.html.erb 文件添加了 meta http-equiv="Content-Type" content="text/html; charset=utf-8"。
我不知道接下来我能做什么...请帮忙:)
您好, 野兽
【问题讨论】:
-
不确定是不是拼写错误,但是 wohnung_controller 顶部的 '#coding: utf-8' 必须是 '#encoding: utf-8'
-
是的,这是一个错字...错误实际上发生在 *.html.erb 文件中。但是我为 unicode 等添加了元标记。但没有任何改变,我仍然遇到问题......
标签: ruby-on-rails encoding utf-8