title: using Bootstrap Navbar Search with form_tag to redirect to resource index with search params
body: <p>I'm trying to put a quick keyword search in my navbar, using Bootstrap's Navbar Search component.  Currently this is using a form_tag as follows</p>
  
  <pre><code>&lt;form class="navbar-search pull-left"&gt;
    &lt;%= form_tag(recipes_path, :method =&gt; :get) do %&gt;
      &lt;%= text_field_tag :keywords, nil, 
        {:class =&gt; "search-query", :placeholder =&gt; "recipes quick search"} %&gt;
      &lt;%= hidden_field_tag :use_keywords, "true" %&gt;
      &lt;%= hidden_field_tag :wide_search, "true" %&gt;
    &lt;% end %&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>This is for a recipe lookup.  I'm using the form to (try to) get keywords, which will be passed as params to the search, which resides in the recipes index action.</p>
  
  <pre><code>def index
    if params[:wide_search].present?
      @search = Search.new
      @search.use_keywords = params[:use_keywords]
      @search.keywords = params[:keywords]
      ... (more params for other search types)
      if params[:wide_search] == "true"
        @recipes = @search.wide_search
      elsif params[:wide_search] == "false"
        @recipes = @search.narrow_search
      end
      @recipes = @recipes.paginate(:page =&gt; params[:page])
    else # no params, just index all
      @recipes = Recipe.paginate(:page =&gt; params[:page])
    end
  end
  </code></pre>
  
  <p>Note that "Search" is a ruby class.  I was thinking of making it into a full-blown resource so I could create and view old searches (maybe they could be looked at to offer suggested searches based on past history, etc), but decided against it.  I still dunno if that was a good idea or not.  If it was an actual resource, it could have RESTful actions and maybe save some problems.  This is not my actual problem, but does anyone have suggestions for this?</p>
  
  <p>Sorry, back to the actual problem -- From the root page or wherever, I would like to be able to type in keywords, press the enter key (within the search bar) and have it redirect to the Recipe Index with the params needed so it can run the search and display the results.</p>
  
  <p>Right now, if I go to the index page and do this, it works fine.  BUT, if I'm in any other page (like the root page, or wherever) and try to type keywords and press enter, it just reloads the current page, although I do see the params in the URL.  So it's not redirecting to Recipe Index.  I must be missing something, but I'm not sure what.  I'm kind of suspicious of the form_tag since there's no actual submit button.  But then it works when I'm in the index page, so I dunno.  Any suggestions appreciated!</p>