views:

33

answers:

1

I'm aware of dynamic routes but I'm a little stumped with this, with the search gem I'm using it performs a get and my route is thus myapp.local/recipes?search=chicken

How can I make this a route? so that it would stay in the recipes controller but appear to the user like a nested route, like this myapp.local/search/chicken

+1  A: 

Your example looks like it's in the local controller with a recipes action and a parameter of search=chicken.

In the routes.rb file

map.recipe_search 'local/search/:search', :controller => "recipes", :action => "search"

It will connect http:///whatever.com/local/search/chicken to the recipes controller, and the search action with a params={:search => "chicken"}

It will also provide you the recipe_search_url function to quickly link to the path.

EmFi