Fellow Stranger
Fellow Stranger

Reputation: 34113

Can I rename a resource in routes.rb?

In routes.rb, I currently have resources :users for the User controller.

A visitor can request the User model by www.mydomain.com/users

I would like to keep the User controller as it is, but have the URL request for people instead, such that a visitor sees the following URL: www.mydomain.com/people

For a single request I can do this by:

get '/users', to: 'users#index'

Is the same possible for for a resource map?

Upvotes: 11

Views: 7507

Answers (1)

Marek Lipka
Marek Lipka

Reputation: 51191

You can use path option of resources method:

resources :users, path: :people

Upvotes: 36

Related Questions