It you define constraint on "id" in parent resource:
resources :fo开发者_开发百科o, constraints: { :id => /CONST/ } do
resources :bar
end
The nested resource will inherits that constraint for its own id, thus the generated routes will be like:
/foo/:foo_id/bar/:id/edit(.:format)
{:id=>/CONST/, :foo_id=>/CONST/, :action=>"edit", :controller=>"bar"}
So, I don't want the "id" parameter of Bar resource to be that restricted.
Currently, I've just map the routes I want manually, one by one, but I am really want to generate it by resources helper. How can I do that?
How about :
resources :foo, constraints: { :id => /CONST/ }
resources :foo, constraints: { :foo_id => /CONST/ } do
resources :bar
end
精彩评论