ruby-on-railsformsutf-8meta-search

rails error in form because of utf8=✓ with meta search


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):

Solution

  • I would try to implement something like this (following the lead from 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 will not work then please look at this question: removing "utf8=✓" from rails 3 form submissions This might be helpful for you.