Non ascii characters in link_to is causing the app to fail in internet explorer 9 in rails app

穿精又带淫゛_ 提交于 2019-12-07 14:49:50

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!