This project is archived and is in readonly mode.

#3996 ✓resolved
Sam Pierson

routing: namespace ignored inside resources

Reported by Sam Pierson | February 18th, 2010 @ 11:57 PM

Using Rails 2.3.5, the following route definition:

map.resources :users do |users|

users.namespace :admin do |admin|
  admin.resources :products
end

end

should produce a route:

user_admin_product GET /x/users/:user_id/admin/products/:id

but it actually produces:

    user_product GET    /users/:user_id/products/:id

i.e. the 'admin' namespace gets lost.

Note however if I nest this all inside a top level namespace, the inner 'admin' namespace reappears:

map.namespace :x do |x|
map.resources :users do |users|

users.namespace :admin do |admin|
  admin.resources :products
end

end

x_user_admin_product GET /x/users/:user_id/admin/products/:id

Comments and changes to this ticket

  • David Trasbo

    David Trasbo June 30th, 2010 @ 12:42 PM

    • Assigned user set to “Ryan Bigg”

    That's the desired behavior. Namespaces are only ment to work in the outer most level, and I think that's the case for both master 2-3-stable.

    "Fixing" this would almost certainly require a major refactoring. Patches are welcome! For now, this can be closed.

  • Mike Riley

    Mike Riley July 29th, 2010 @ 08:15 PM

    • State changed from “new” to “resolved”
    • Importance changed from “” to “Low”

    Hello,

    Closing this out based on David's reply.

    Mike Riley

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