I have a form which contains some text_fields. One of them is the zip code field. It has a button "Search" that calls an specific action "search_zip_code" which returns the address values associated with that field. How can I invoke this action inside a form_for tag? I have already tried a form_tag nested to it, but the submit action invokes the :create method. If I use a "link_to", I can't pass the zip code entered by the user. What is the best approach for that?
<%= form_for(@model) do |m|%>
<%= m.label :field_1 %>
<%= m.text_field :field_1 %>
<%= m.label :field_2 %>
<%= m.text_field :field_2 %>
<div class="field">
<%= form_tag("/search_zip_code", method: "get") do %>
<%= label_tag(:zip, "ZIP Code:") %>
<%= text_field_tag(:zip) %>
<%= submit_tag("Search") %>
<% end %>
</div>
<%= m.submit %>
<% end %>
Why the action "/search_zip_code" isn't reached by the submit_tag button? Even if I change this route to a :post method, it doesn't work.
Thank you,
Guilherme