Question

What would be the correct way to convert this rails 2.1 route,

map.connect '/ads/:id', :controller=>'ads', :action=>'show'

To a rails 4.1 route?

Thanks in advance, Nathan :-)

Was it helpful?

Solution 2

If you want to enable full RESTful Routes(create/new/show/delete) to your Adscontroller.Use below one

resources :ads

If you want to enable only Show method routes to your Adscontroller. Use below one

resources :ads, only: :show

For further Reference.Please read this documentation : Resources Routes

OTHER TIPS

Assuming you only have the show action for ads, you need to define the route as follows:

resources :ads, only: :show

This only creates the route GET ads/:id. Be sure to read the Rails documentation on resourceful routing.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top