Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

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

#4251

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=

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

State: invalid
Milestone: none
Assigned to: Jeremy Kemper Jeremy Kemper
Importance: none

Activity

  1. Leonhardt Wille
    Leonhardt Wille
    • Assigned user set to Jeremy Kemper

    March 22nd, 2010 @ 08:47 AM

  2. Jeremy Kemper
    Jeremy Kemper
    • State changed from new to invalid

    Hey, for UTF-8 support in sqlite you need the sqlite3-ruby gem from http://github.com/qoobaa/sqlite3-ruby

    March 22nd, 2010 @ 03:30 PM

  3. Leonhardt Wille
    Leonhardt Wille

    Yeah, thanks :-)

    To my eyes, this isn't documented anywhere. Now it is :-)

    March 22nd, 2010 @ 08:58 PM