This project is archived and is in readonly mode.

#5293 ✓invalid
Timo Mika Gläßer

methods for routes not getting generated

Reported by Timo Mika Gläßer | August 4th, 2010 @ 11:10 AM

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?

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Pages