In my view, I want to create one single search field with two buttons. Once I click the first one I want to use the string in the search field for searching for Users. When I click the second button I want to use the string in the field for searching for posts.
I think a solution whould look something like this:
<%= form_tag([users_path, posts_path], method: 'get', id: 'search-form') do %>
<%= text_field_tag(:search, params[:search], id: 'search-field', placeholder: "Search") %>
<%= button_tag(:id => "search-user-btn", :controller => :users) do %>
<i class="icon-search-user"></i>
<% end %>
<%= button_tag(:id => "search-post-btn", :controller => :posts) do %>
<i class="icon-search-post"></i>
<% end %>
<% end %>
Is it possible to have one text_field and share it for two buttons routed each for a different controller (users and posts in this case)?
How can I do this?