Single custom param name in routes for nested resources Rails 4.1

后端 未结 2 1401
孤街浪徒
孤街浪徒 2021-02-09 05:04

I have question about param name for nested resources in rails routes For example i have:

resources :controller1, param: :controller_id do
  resources :controlle         


        
2条回答
  •  梦毁少年i
    2021-02-09 05:38

    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
    ...
    

提交回复
热议问题