Muhambi
Muhambi

Reputation: 3522

Change resources path

I'm using Rails 4

I have a routes.rb file that looks like:

resources :books

However, I'd like the urls in the application to end up looking like /b/101 instead of /books/101.

I realize I could go through and rename each resource path individually, but is there not a way to do this by changing the resources somehow? Kind of like how you can change the params by doing resources :books, params: :new_id?

Upvotes: 2

Views: 163

Answers (1)

Arup Rakshit
Arup Rakshit

Reputation: 118261

Here is what you can do

resources :books, path: 'b'

Upvotes: 5

Related Questions