Within a category, "Seach all posts" checkbox, how to?

Posted by benoror on Stack Overflow See other posts from Stack Overflow or by benoror
Published on 2010-06-03T22:59:39Z Indexed on 2010/06/06 8:42 UTC
Read the original article Hit count: 339

Filed under:
|

Hi, I have set up my routes so I can search all posts with:

/posts/search/foobar

or search inside a category

/posts/category/1/search/foobar 

It works pretty well, when someone is browsing an specific category it does search just posts that belongs to that category.

When inside a category, I want to place a checkbox to "Search all the posts"

My search form:

<% form_for :posts, :url => {:controller => :posts, :action => :index} do |f| %>
  Search: <%= f.text_field :search %>
  <% if params[:cat] %>
    <%= f.check_box :ignore_cat, '1', false %> Search all the posts?
  <% end %>
  <%= f.submit 'Go' %>
<% end %>

How can I force to change the route?

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about ruby