In my app the following routes definition
resources :organizations do
resources :branches
end
produces
No route matches {:controller=>"branches", :action=>"destroy",
:organization_id=>#<Organization _id: 4c589f81c0b2101cd1000011, ...>,
:id=>#<Branch _id: 4c589f81c0b2101cd1000012, ...>}
when I call it like this
organization_branch_path(organization, branch)
whereas this produces the correct url without errors
organization_branch_path(:organization_id => 23, :id => 23)
Notably the output of rake routes does not include the method
name for GET but I am not sure if this used to be the case in
earlier versions. The relevant output of rake routes is
GET /organizations/:organization_id/branches(.:format) {:controller=>"branches", :action=>"index"}
organization_branches POST /organizations/:organization_id/branches(.:format) {:controller=>"branches", :action=>"create"}
new_organization_branch GET /organizations/:organization_id/branches/new(.:format) {:controller=>"branches", :action=>"new"}
GET /organizations/:organization_id/branches/:id(.:format) {:controller=>"branches", :action=>"show"}
PUT /organizations/:organization_id/branches/:id(.:format) {:controller=>"branches", :action=>"update"}
organization_branch DELETE /organizations/:organization_id/branches/:id(.:format) {:controller=>"branches", :action=>"destroy"}
edit_organization_branch GET /organizations/:organization_id/branches/:id/edit(.:format) {:controller=>"branches", :action=>"edit"}
I think it used to work like the version where you just pass
instances of objects before and not having to think about the names
of the required ids.
I have to mention that I am using Mongoid and do not have
ActiveRecord included in my configuration. Not sure yet whether you
do any reflection on that end - which IMHO would not be required to
generate and/or recognize the routes. You can just call to_param on
all objects being passed in order of nesting and associated the ids
by convention, right?