4

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):
guts
  • 381
  • 1
  • 9
  • 22

2 Answers2

3

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.

Community
  • 1
  • 1
Ireneusz Skrobis
  • 1,533
  • 1
  • 11
  • 12
-1

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

Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8
dexter
  • 13,365
  • 5
  • 39
  • 56
  • @pefs commented "Where in environment.rb I need add [these lines] First line, last line?" – drs Jul 16 '14 at 14:20