问题
I have a recipe search form in my rails app. In a recipe's detail, I have a link to return to the results. The line I added is:
link_to "Return to search", :back
In Internet Explorer 9, because the :back link has a utf-8=✓ in the url, I get an encoding error. The description of the error is:
ActionView::Template::Error (incompatible character encodings: ASCII-8BIT and UTF-8)
Let there be known the encoding in my application.rb is set to utf-8. I'm using ruby 1.9.2.
回答1:
On Ruby 1.9.x you should specify the encoding on each .rb file. Add this on the first line of each:
# -*- coding: UTF-8 -*-
来源:https://stackoverflow.com/questions/9071271/non-ascii-characters-in-link-to-is-causing-the-app-to-fail-in-internet-explorer