问题描述
我的轨道应用程序中有一个食谱搜索表单。在食谱的细节中,我有一个链接来返回结果。我添加的行是: link_to返回搜索,:back
在Internet Explorer 9中,因为:back link在url中有一个utf-8 =✓,我收到一个编码错误。错误的描述是:
ActionView :: Template :: Error(不兼容的字符编码:ASCII-8BIT和UTF-8)
让我们知道我的application.rb中的编码设置为utf-8。我正在使用ruby 1.9.2。
在Ruby 1.9.x上,您应该在每个.rb文件上指定编码。在每个的第一行添加:
# - * - 编码:UTF-8 - * -
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.
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 -*-
这篇关于link_to中的非ASCII字符导致应用程序在rails应用程序中的Internet Explorer 9中失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!