This is possible but you will basically be setting up a rule like this
"whenever we get a url like /foo/bar then we want the category
''foo'' and
the recipe ''bar''"
That might clash with the existing url schema on your site. If you want
to go for it though then set up your routes like this:
map.category_recipe '':category_name/:recipe_name'',
:controller =>
''recipes'', :action => ''show'', :conditions
=> {:method => :get}
Make sure you put it down the bottom, above the
map.connect '':controller/:action/:id''
section.
Now the url http://localhost/italian/special-pasta-sauce
should call the recipes controller, with params like {:recipe_name =>
"special-pasta-sauce", :category_name => "italian"}
And in your views you can say eg
category_recipe_path(category, recipe)
The above assumes that you''ve overriden to_param in Category and Recipe
to use the name of the object instead of it''s id.
If you''re using slus or something instead of name then you can
substitute appropriately.
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.