# Problems with 3 deep restful nesting

**URL:** <https://www.ruby-forum.com/t/problems-with-3-deep-restful-nesting/131048>\
**Category:** Rails\
**Created:** [March 5, 2008, 4:15pm UTC](https://www.ruby-forum.com/t/problems-with-3-deep-restful-nesting/131048 "2008-03-05T16:15:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![betaband](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/9d8465/32.png) [@betaband](https://www.ruby-forum.com/u/betaband)\
**Post date:** [March 5, 2008, 4:15pm UTC](https://www.ruby-forum.com/t/problems-with-3-deep-restful-nesting/131048/1 "2008-03-05T16:15:04Z")

</div>

I have a

:user has\_many :events has\_many :signups

map.resources :users do |user|  
user.resources :events do |event|  
event.resources :signups  
end  
end

But in the 3rd nested resource im having trouble with the form\_for( )  
function.  
The link to the page where the form lies works and i linked to it  
with: new\_user\_event\_signup\_path(@user, @event) but the page  
doesnt render with anything i have tried, and i have tried…!

so far ive tried:

form\_for([@user, @signup])  
form\_for([@user, @event])  
form\_for([@event, @signup])

and everything in between…

---

<div class="post-metadata">

**Author:** ![betaband](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/9d8465/32.png) [@betaband](https://www.ruby-forum.com/u/betaband)\
**Post date:** [March 5, 2008, 4:21pm UTC](https://www.ruby-forum.com/t/problems-with-3-deep-restful-nesting/131048/2 "2008-03-05T16:21:38Z")

</div>

oh, and i have tried all variations of 3 instances aswell… such as  
form\_for([@user, @event, @signup])

---

<div class="post-metadata">

**Author:** ![betaband](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/9d8465/32.png) [@betaband](https://www.ruby-forum.com/u/betaband)\
**Post date:** [March 5, 2008, 4:22pm UTC](https://www.ruby-forum.com/t/problems-with-3-deep-restful-nesting/131048/3 "2008-03-05T16:22:48Z")

</div>

3 levels deep nesting is not nessessary, as the event as parent to the  
signup is enough to keep a unique scope on the signup object.

1. use these routes:

map.resources :users do |user|  
user.resources :events  
end  
map.resources :events do |event|  
event.resources :signups  
end

1. and this form defintion:  
form\_for([@event, @signup])

and everything is fine.

---

<div class="post-metadata">

**Author:** ![betaband](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/9d8465/32.png) [@betaband](https://www.ruby-forum.com/u/betaband)\
**Post date:** [March 5, 2008, 4:48pm UTC](https://www.ruby-forum.com/t/problems-with-3-deep-restful-nesting/131048/4 "2008-03-05T16:48:08Z")

</div>

Thanks! It workus!

---

<div class="post-metadata">

**Author:** ![betaband](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/9d8465/32.png) [@betaband](https://www.ruby-forum.com/u/betaband)\
**Post date:** [March 5, 2008, 4:41pm UTC](https://www.ruby-forum.com/t/problems-with-3-deep-restful-nesting/131048/5 "2008-03-05T16:41:06Z")

</div>

Also, you might want to check Jamis B.'s post on why 3 deep nested  
resources may not be a good practice.

[http://weblog.jamisbuck.org/2007/2/5/nesting-resources](http://weblog.jamisbuck.org/2007/2/5/nesting-resources)
