ambertch
ambertch

Reputation: 7649

Making a plural rails "resources" url into singular

I have in my routes.rb file

resources :shops

which I want, since I want to separate index and show routes, but this leads to a /shops/ url

I'd actually like it to make to /shop - what's the easiest way to do this?

Thanks!

Upvotes: 0

Views: 384

Answers (1)

mind.blank
mind.blank

Reputation: 4880

If you want them all to be /shop shop/1 etc. then do:

resources :shops, path: "shop"

Otherwise maybe you can do

resources :shops, except: :show
# then
resources :shops, only: :show, path: "shop"
# or
get "shop/:id", to: "shops#show", as: :shop

Upvotes: 4

Related Questions