# Routing error with nested resources

**URL:** <https://www.ruby-forum.com/t/routing-error-with-nested-resources/113725>\
**Category:** Rails\
**Created:** [September 4, 2007, 11:48am UTC](https://www.ruby-forum.com/t/routing-error-with-nested-resources/113725 "2007-09-04T11:48:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![biot023](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/7ab992/32.png) [@biot023](https://www.ruby-forum.com/u/biot023)\
**Post date:** [September 4, 2007, 11:48am UTC](https://www.ruby-forum.com/t/routing-error-with-nested-resources/113725/1 "2007-09-04T11:48:24Z")

</div>

Hi – I have a routes.rb file with the following in it:

`
  map.resource :admin do |admin|
    admin.resources :users
    admin.resources :clients do |client|
      client.resources :client_properties
    end
    admin.resources :areas
    admin.resources :properties
  end
`

My problem is when I try to access the show or edit actions of the  
client\_properties resource.  
The function client\_property\_path( client, property ) returns the  
correct url – “/clients/1/client\_properties/2” – but the routing then  
fails on this with the following error:

c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action\_controller/routing.rb:1273:in `raise\_named\_route\_error': client\_property\_url failed to generate from {:client\_id=\>"2", :controller=\>"client\_properties", :action=\>"show"}, expected: {:controller=\>"client\_properties", :action=\>"show"}, diff: {:client\_id=\>"2"}

(NOTE – it seems to taking the property id as the client id.)

By my understanding there should be no cause for an error here.  
Can anyone shed any light on what I’m getting wrong?  
Or if maybe my understanding of how resources & nesting works is in  
error, could they point that out?  
& thanks in advance for any & all assistance,  
Doug.

---

<div class="post-metadata">

**Author:** ![biot023](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/7ab992/32.png) [@biot023](https://www.ruby-forum.com/u/biot023)\
**Post date:** [September 4, 2007, 11:50am UTC](https://www.ruby-forum.com/t/routing-error-with-nested-resources/113725/2 "2007-09-04T11:50:06Z")

</div>

> The function client\_property\_path( client, property ) returns the  
> correct url – “/clients/1/client\_properties/2”…

Sorry – that should read that the correct url returned is:  
“/admin/clients/1/client\_properties/2”.

Doug.
