渲染德语特殊字符时出现模板错误
我在 arch linux 上使用以下版本的 Ruby 和 Rails
[hardik@sunshine: kandibank ]$ ruby --version
ruby 1.9.1p429 (2010-07-02 revision 28523) [x86_64-linux]
[hardik@sunshine: kandibank ]$ rails --version
Rails 2.3.8
我在开发模式下使用 sqllite 数据库。
我可以存储具有德语特殊字符(元音变音)的字符串,而无需 一个问题,即穆勒。
但是当 Rails 尝试渲染一个从中提取相同字符串的页面时 数据库崩溃并显示以下错误消息。奇怪的是 它正确呈现字符串“Löchen”,该字符串不是来自 数据库。
ActionView::TemplateError (incompatible character encodings: UTF-8 and
ASCII-8BIT) on line #28 of app/views/candidates/index.html.erb:
25: <td><%=h candidate.notes %></td>
26: <td><%= link_to 'Ansehen', candidate %></td>
27: <td><%= link_to 'Editieren', edit_candidate_path(candidate)
%></td>
28: <td><%= link_to 'Löchen', candidate, :confirm => 'Are you
sure?', :method => :delete %></td>
29: </tr>
30: <% end %>
31: </table>
app/views/candidates/index.html.erb:28:in `block in
_run_erb_app47views47candidates47index46html46erb'
app/views/candidates/index.html.erb:16:in `each'
app/views/candidates/index.html.erb:16
app/controllers/candidates_controller.rb:8:in `index'
<internal:prelude>:8:in `synchronize'
/usr/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
/usr/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
/usr/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'
Rendered rescues/_trace (44.0ms)
Rendered rescues/_request_and_response (0.2ms)
Rendering rescues/layout (internal_server_error)
有什么想法吗?
问候, 哈迪克
I am using following versions of Ruby and Rails on arch linux
[hardik@sunshine: kandibank ]$ ruby --version
ruby 1.9.1p429 (2010-07-02 revision 28523) [x86_64-linux]
[hardik@sunshine: kandibank ]$ rails --version
Rails 2.3.8
I am using the sqllite database in development mode.
I can store a string having German special characters (umlauts) without
a problem i.e. Müller.
But when Rails try to render a page which extracts the same string from
the database it crashes with following error message. It is strange that
it renders the string "Löchen" properly which doesn't come from
database.
ActionView::TemplateError (incompatible character encodings: UTF-8 and
ASCII-8BIT) on line #28 of app/views/candidates/index.html.erb:
25: <td><%=h candidate.notes %></td>
26: <td><%= link_to 'Ansehen', candidate %></td>
27: <td><%= link_to 'Editieren', edit_candidate_path(candidate)
%></td>
28: <td><%= link_to 'Löchen', candidate, :confirm => 'Are you
sure?', :method => :delete %></td>
29: </tr>
30: <% end %>
31: </table>
app/views/candidates/index.html.erb:28:in `block in
_run_erb_app47views47candidates47index46html46erb'
app/views/candidates/index.html.erb:16:in `each'
app/views/candidates/index.html.erb:16
app/controllers/candidates_controller.rb:8:in `index'
<internal:prelude>:8:in `synchronize'
/usr/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
/usr/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
/usr/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'
Rendered rescues/_trace (44.0ms)
Rendered rescues/_request_and_response (0.2ms)
Rendering rescues/layout (internal_server_error)
Any idea ?
regards,
Hardik
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是 Ruby 1.9.x 和 ERB 的问题。有一个 Rails Lighthouse 问题跟踪系统上的整个线程 关于它。如果可以的话,我建议您回退到 Ruby 1.8.7。
This is a problem with Ruby 1.9.x and ERB. There's a whole thread on the Rails Lighthouse issue tracking system about it. I would recommend dropping back to Ruby 1.8.7 if you are able to.