Reputation: 4116
I have the following in my routes:
resources :collection_pages, :only => [:show, :index]
Right now its going to wwww.mysite.com/collection_pages for index
and collection_pages/:id
for show
I need it to go to /collection
s instead for index
and /collection/:id
for show
I tried path: :collections
, but its not behaving as I'd like.
What's the best way to achieve this using ressources?
Upvotes: 0
Views: 780
Reputation: 5598
Along with the SO answer @Tamer.Shlash notes, you could use custom matchers in your routes file:
match '/collection', to: 'collection_pages#index', as: 'collection_index'
match '/collection/:id', to: 'collection_pages#show', as: 'collection_show'
Adding the as: 'xxxx' to the match allows you to use friendly path and url helpers in your views:
redirect_to collection_index_path
Upvotes: 2