I don’t understand why it is happening. Here is my form:
<%= form_tag controller: :static_pages, action: :index, method: :get do %>
<%= text_field_tag :search_text %>
<%= submit_tag "Search", id: :search_button %>
<% end %>
However, instead of sending the valeu of search_text through the URL, it is calling the post method and sending the method=get in the URL.
http://localhost:3000/static_pages/index?method=get
Any idea the reason?
It’s interpreting the
method: :getas part of the route the form should go to, rather than as additional options toform_tagitself. Wrapcontroller: :static_pages, action: :indexin a hash and add parentheses to the method call. Then it should work: