sen*_*sov 6 rest ruby-on-rails constraints nested-resources ruby-on-rails-3
你在父资源中定义了对"id"的约束:
resources :foo, constraints: { :id => /CONST/ } do
resources :bar
end
Run Code Online (Sandbox Code Playgroud)
嵌套资源将为其自己的id继承该约束,因此生成的路由将如下所示:
/foo/:foo_id/bar/:id/edit(.:format)
{:id=>/CONST/, :foo_id=>/CONST/, :action=>"edit", :controller=>"bar"}
Run Code Online (Sandbox Code Playgroud)
所以,我不希望Bar资源的"id"参数受到限制.
目前,我只是逐个手动映射我想要的路由,但我真的想通过资源助手来生成它.我怎样才能做到这一点?
怎么样 :
resources :foo, constraints: { :id => /CONST/ }
resources :foo, constraints: { :foo_id => /CONST/ } do
resources :bar
end
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
713 次 |
最近记录: |