TemplateError在渲染德语特殊字符时

时间:2010-07-23 05:45:32

标签: ruby-on-rails ruby encoding

我在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数据库。

我可以存储没有德语特殊字符(变音符号)的字符串 一个问题,即Müller。

但是当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)

有什么想法吗?

的问候, Hardik

1 个答案:

答案 0 :(得分:1)

这是Ruby 1.9.x和ERB的问题。关于它的Rails Lighthouse问题跟踪系统有一个whole thread。如果你能的话,我建议你回到Ruby 1.8.7。