I am putting a search field on my homepage using the form_tag helper method.
However when I do the following code
<%= form_tag(dogs_path) %> <%= text_field_tag "search" %> <%= submit_tag "Search" %> <% end %>
Instead of it going to the index, it seems to be going to the create action instead.
The only way I managed to get around it was by doing
<%= form_tag(dogs_path, method: :get) %> but that resulted in the URL containing the utf-8 and commit params it it.
I just want it so when you press search it takes you to the url www.example.com/dogs?search=test
Any help or advice would be appreciated.
After doing a little more digging, It seems I was half way there changing the method to
GET after watching this RailsCast, the way I stop the commit=search from appearing is by doing
name: nil on the
submit_tag helper method.
How do I stop the utf-8 parameter showing up?