# Rails 2.0 and nested routes

**URL:** <https://www.ruby-forum.com/t/rails-2-0-and-nested-routes/120558>\
**Category:** Rails\
**Created:** [November 18, 2007, 3:07pm UTC](https://www.ruby-forum.com/t/rails-2-0-and-nested-routes/120558 "2007-11-18T15:07:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![supasta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ebca7d/32.png) [@supasta](https://www.ruby-forum.com/u/supasta)\
**Post date:** [November 18, 2007, 3:07pm UTC](https://www.ruby-forum.com/t/rails-2-0-and-nested-routes/120558/1 "2007-11-18T15:07:50Z")

</div>

I have seen the new way to define RESTful routes. How would you define  
the following routes in the newstyle?

map.resources :dinners do |dinner|  
dinner.resources :dishes do |dish|  
dish.resources :side\_courses  
end  
end

Any ideas?

Thanks!  
Chris

---

<div class="post-metadata">

**Author:** ![supasta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ebca7d/32.png) [@supasta](https://www.ruby-forum.com/u/supasta)\
**Post date:** [November 18, 2007, 8:32pm UTC](https://www.ruby-forum.com/t/rails-2-0-and-nested-routes/120558/2 "2007-11-18T20:32:39Z")

</div>

Chris W. wrote:

> I have seen the new way to define RESTful routes. How would you define  
> the following routes in the newstyle?
> 
> map.resources :dinners do |dinner|  
> dinner.resources :dishes do |dish|  
> dish.resources :side\_courses  
> end  
> end
> 
> Any ideas?

That’s totally current and up-to-date for Rails 2.0. If by “new way”  
you mean the :has\_many and :has\_one options, those are just shortcuts  
for nesting resources or singular resource, respectively. I don’t think  
you can do multiple levels that way though.

–  
Josh S.  
[http://blog.hasmanythrough.com](http://blog.hasmanythrough.com)

---

<div class="post-metadata">

**Author:** ![supasta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ebca7d/32.png) [@supasta](https://www.ruby-forum.com/u/supasta)\
**Post date:** [November 18, 2007, 8:40pm UTC](https://www.ruby-forum.com/t/rails-2-0-and-nested-routes/120558/3 "2007-11-18T20:40:43Z")

</div>

The :has\_one and :has\_many are the shortcuts I was eluding to. Just  
making sure I am doing things the correct way with Rails 2.0.

Thanks  
Chris

Josh S. wrote:

> Chris W. wrote:
> 
> > I have seen the new way to define RESTful routes. How would you define  
> > the following routes in the newstyle?
> > 
> > map.resources :dinners do |dinner|  
> > dinner.resources :dishes do |dish|  
> > dish.resources :side\_courses  
> > end  
> > end
> > 
> > Any ideas?
> 
> That’s totally current and up-to-date for Rails 2.0. If by “new way”  
> you mean the :has\_many and :has\_one options, those are just shortcuts  
> for nesting resources or singular resource, respectively. I don’t think  
> you can do multiple levels that way though.
> 
> –  
> Josh S.  
> [http://blog.hasmanythrough.com](http://blog.hasmanythrough.com)
