由于 utf8=✓ 导致表单出现 Rails 错误通过元搜索
我在使用元搜索的搜索表单中遇到问题:
当我提交搜索表单(方法 get)时,由于 Rails 添加了 utf8=✓
参数,出现 500 错误。
http://localhost:3000/items?utf8=✓&search[brand_contains]=levi
如果我删除网址中的复选标记 (✓) 并按 Enter 键,效果很好。
我使用 Rails 3.0.9 和 ruby 1.9.2。
我真的不知道如何解决这个问题,所以如果您有任何建议,我将很高兴听到。 感谢您的帮助。
编辑:
这是我的表格:
= form_for @search, :class => "recherche" do |f|
= f.label :brand
= f.text_field :brand_contains
= f.submit "Rechercher"
以及错误:
Started GET "/items?utf8=%E2%9C%93&search[brand_contains]=levi&commit=Rechercher" for 127.0.0.1 at 2011-09-02 17:39:39 +0200
ArgumentError (invalid byte sequence in US-ASCII):
I have an issue in a search form with meta search :
When I submit my search form (method get) I have a 500 error because of the utf8=✓
param added by rails.
http://localhost:3000/items?utf8=✓&search[brand_contains]=levi
If I delete the check mark (✓) in the url and press enter it works well.
I use rails 3.0.9 and ruby 1.9.2.
I really don't know how to fix this issue so if you have any suggestion I will be happy to hear them.
Thank you for your help.
Edit :
Here is my form :
= form_for @search, :class => "recherche" do |f|
= f.label :brand
= f.text_field :brand_contains
= f.submit "Rechercher"
And the error :
Started GET "/items?utf8=%E2%9C%93&search[brand_contains]=levi&commit=Rechercher" for 127.0.0.1 at 2011-09-02 17:39:39 +0200
ArgumentError (invalid byte sequence in US-ASCII):
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我会尝试实现这样的东西(按照我的评论中的链接引导):
如果这不起作用,那么请看看这个问题:从 Rails 3 表单提交中删除“utf8=✓” 这可能对您有帮助。
I would try to implement something like this (following the lead from link from my comment):
if this will not work then please look at this question: removing "utf8=✓" from rails 3 form submissions This might be helpful for you.
您可以尝试将以下行添加到environment.rb中:
Can you try adding the following line to environment.rb: