Reputation: 19596
I have my resources already defined, but a client wants to change the names of the URLs to match their brand (e.g. something like "catalog" when the resource is currently "products"). Can I specify a different controller name with a resource so I can get all the built-in resources functionality without having to actually rename the controller and model names?
Upvotes: 17
Views: 11797
Reputation: 35645
The rails guide specifies how to use specific controllers for certain routes.
You can do something like this:
Rails.application.routes.draw do
resources :products, controller: "catalog"
end
This maps products
to the catalog
controller.
Upvotes: 6
Reputation: 107728
For the record: map.resources :products, :controller => "catalog"
is how you do this.
Upvotes: 37
Reputation: 19596
Okay it looks like it's as simple as adding the controller name, and it seems to be working. Nevermind!
Upvotes: 0