Search code examples
ruby-on-railsrubyrails-routing

I'm having problems with rails 4.1 routing


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 :-)


Solution

  • 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