Reputation: 545
I have this url working now on my Rails 4.2 app - https://example.org/causes/help-family What do I need to do to change the url's to look like this - https://example.org/help-family without the "causes" controller showing up in the route? https://example.org/causes should still continue to list all the causes.
This is what part of my routes file looks like.
resources :causes, only: [:new, :create, :index, :show] do
get :thankyou
resources :donations, only: [:new, :create, :show ]
end
Thank you!
Upvotes: 0
Views: 554
Reputation: 659
You can do:
resources :causes, path: '/', only: [:new, :create, :show] do
get :thankyou
get :index, path: 'causes', on: :collection
resources :donations, only: [:new, :create, :show ]
end
This is assuming you only want to keep the 'causes' in the path for the index page.
Upvotes: 1