views:

30

answers:

1

Hi

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

+1  A: 

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.

John Topley
Use RVM to install multiple rubies:http://rvm.beginrescueend.com/Works fine on Arch and you don't have to keep back any package upgrades.
Teoulas
Yes, RVM is a great solution for development.
John Topley
Hi John, the link you posted doesn't work. I also came across some patch to rails, but I am not sure how to apply it. So, if I understood you correctly, I should use Ruby 1.8 instead.
rangalo
By the way, is rvm an arch package or a gem ?
rangalo
@rangalo Sorry, I've edited my answer to include the correct link now. Ruby 1.9.1 is pretty bleeding edge right now. I'd recommend using Ruby 1.8.7 with Rails 2.3.8. As Teoulas said, RVM is a great way to manage multiple Ruby installations.
John Topley
Thanks I have installed rvm and it seems to work with ruby 1.8.7
rangalo