Strange routing
Posted
by astropanic
on Stack Overflow
See other posts from Stack Overflow
or by astropanic
Published on 2010-06-15T20:57:44Z
Indexed on
2010/06/15
21:22 UTC
Read the original article
Hit count: 310
How I can setup my rails app to respond to such urls:
http://mydomain.com/white-halogene-lamp
http://mydomain.com/children-lamps
http://mydomain.com/contact-form
The first one should link to my products controller, and show my product with this name
The second one should link to my categories controller, and show the category with this name
The third one should link to my sites controller, and show the site with this title.
All three models (product, category, site) have a method to_seo, giving the mentioned above urls (after the slash)
I know it's not the restful way, but please don't disuss here, it is wrong approach or not, that's not the question.
The question is how to accomplish this weird routing ?
I know we have catch all routes, but how I can tell rails to use different controllers on different urls in the catch all route ? Or have You an better idea ?
I would avoid redirects to other urls.
© Stack Overflow or respective owner