Rails error in form due to utf8 = ✓ with meta search

I have a problem in the search form with meta search:

When I submit my search form (get method), I have 500 error due to utf8=✓ parameter added by rails.

http://localhost:3000/items?utf8=✓&search[brand_contains]=levi

If I remove the checkmark (✓) 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 problem, so if you have any suggestions, I will be glad 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): 
+4
source share
2 answers

I would try to implement something like this (following the example link from my comment):

 <form action="<%= search_path %>" method="get" class="recherche" > <%= text_field_tag 'search[brand_contains]' %> <%= submit_tag "Rechercher", :name => nil %> </form> 

if this does not work, please look at this question: remove "utf8 = ✓" from the rails 3 form submission This may be useful for you.

+3
source

Can you try adding the following line to environment.rb:

 Encoding.default_external = Encoding::UTF_8 Encoding.default_internal = Encoding::UTF_8 
-1
source

All Articles