I have a systemwide search field with a submit button (submit_tag).
<%= submit_tag “Search” %>
I wonder if there is a way to link to a chosen path when the user
presses the submit button, in my case to the root_path. Or should i
use something else instead of ‘submit_tag’?
I have another question on a similar topic, in my search field I have
a default text value (:value => “Search on…”), is there an easy
Rails way to clear the default value when the user activates the
Examples or links would greatly be appreciated.
The link that a form submits to is set in the form tag itself, not the
button. Here’s what I mean:
<% form_tag documents_path, :method => ‘get’ do %>
<%= link_to("Show All") if params[:q] %>
<%= text_field_tag :q, params[:q] %>
<%= submit_tag "Search", :name => nil, :id => 'search_submit' %>
<% end %>
form builder syntax.
to keep from submitting the default value. Be sure to check in your
controller for that explicit value and ignore the search event in that
Thanks a lot! That worked.
Do you have any tips on my second question?