2010-07-23 108 views
1

我使用Arch Linux的Ruby和Rails的下列版本TemplateError而渲染德國特殊字符

[[email protected]: kandibank ]$ ruby --version 
ruby 1.9.1p429 (2010-07-02 revision 28523) [x86_64-linux] 
[[email protected]: 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

這是用Ruby 1.9.x的和再培訓局的一個問題。 Rails Lighthouse問題跟蹤系統上有關於它的whole thread。如果可以的話,我會建議退回到Ruby 1.8.7。

+0

使用RVM安裝多個紅寶石: http://rvm.beginrescueend.com/ 在Arch上工作正常,您不必禁用任何軟件包升級。 – Teoulas 2010-07-23 08:41:39

+0

是的,RVM是一個很好的開發解決方案。 – 2010-07-23 08:55:01

+0

嗨,約翰,你發佈的鏈接不起作用。我也遇到了一些補丁,但我不知道如何應用它。所以,如果我正確地理解了你,我應該用Ruby 1.8來代替。 – rangalo 2010-07-23 09:34:30