Search This Blog

Sunday, February 13, 2011

How to do this with routing in Rails?

Programmer Question

Say we have a simple resource called news:



resources :news


The generated paths are in this form /news/:id. I would like to provide a shortcut for this by dropping the /news/, so that /1/ goes to news#show with id 1 and the same for all the other resourceful actions of news.



I figured it's probably something along the lines of



match '/:id(/:action)', :controller => 'news'


but this isn't working.



Find the answer here

No comments:

Post a Comment

Related Posts with Thumbnails