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 %&开发者_Go百科gt;
<% 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?
look up polymorphic_path, I think that will get you going the right direction.
精彩评论