Reputation: 101
I have question about param name for nested resources in rails routes For example i have:
resources :controller1, param: :controller_id do
resources :controller2
end
and i have routes:
controller1/:controller_id/
...
controller1/:controller_controller_id/controller2/...
...
I want single :controller_id for controller1 I know it's looks bad, but How do this? Thanks!
Upvotes: 7
Views: 3427
Reputation: 1360
how about this:
resources :controller1, param: :controller_id do
member do
resources :controller2
end
end
will generate
GET /controller1/:controller_id
GET /controller1/:controller_id/controller2
GET /controller1/:controller_id/controller2/:id
...
Upvotes: 19
Reputation: 1387
Try this and see;
resources :controller1, param: :controller_id, path: "" do
resources :controller2, path: ""
end
Upvotes: -1