Custom URLs with routes.rb
Using the routes.rb file, we can create custom URLs. It is important to note that the following is valid :
map.connect ':permalink', :action=>'list', :controller=>'categories'
whereas the following are not valid:
map.connect ':permalink-:id', :action=>'list', :controller=>'categories'
map.connect ':permalink_id.html', :action=>'list', :controller=>'categories'
map.connect ':permalink-:id.html', :action=>'list', :controller=>'categories'
3 Comments:
Can you tell me how it's possible to generate an url with .html without using:
map.connect ':controller/:action/:id/:title.html'
?
Thank you
This comment has been removed by the author.
you can make it in http server level.
If you are using apache then use mod_rewrite and rewrite rules. If you are using webrick then you can check this article
You can also check this project RDR :: Rails Dynamic Routes on rubyforge, which is a little step towards having dynamic routes in rails.
--
Nilesh
Post a Comment
<< Home