This project is archived and is in readonly mode.

#4251 ✓invalid
Leonhardt Wille

view helpers: incompatible character encodings: ASCII-8BIT and UTF-8

Reported by Leonhardt Wille | March 22nd, 2010 @ 12:21 AM

Some view helpers (at least link_to and render) crash due to encoding errors although template is correctly saved in UTF8.

prerequisites:

rvm 1.9.1
gem install rails --pre

reproduce:

rails fails
cd fails
bundle install
rails generate scaffold failure name:string
rake db:migrate
echo "Failure.create! :name=>'äöä';puts Failure.first.name.encoding" | rails c
rails s

now point your browser to localhost:3000/failures and notice that the view renders nicely, including
after hitting CTRL+C, paste this into the console:

echo "<%=link_to 'ÄÖÜßäöü', failures_path%>">>app/views/failures/index.html.erb
rails s

when you reload the failures page, you should see an Exception "incompatible character encodings: ASCII-8BIT and UTF-8".

I don't see any workaround for this, as using HTML entities like &Auml; will not work with link_to.
This may be also be an issue with the default sqlite3-ruby gem, as the encoding seems to be ASCII-8BIT for the new value.

$ rails -v
Rails 3.0.0.beta

$ ruby -v
ruby 1.9.1p378 (2010-01-10 revision 26273) [i386-darwin10.2.0]

$ locale
LANG="de_DE.UTF-8"
LC_COLLATE="de_DE.UTF-8"
LC_CTYPE="de_DE.UTF-8"
LC_MESSAGES="de_DE.UTF-8"
LC_MONETARY="de_DE.UTF-8"
LC_NUMERIC="de_DE.UTF-8"
LC_TIME="de_DE.UTF-8"
LC_ALL=

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

People watching this ticket

Pages