# Nested resource

**URL:** <https://www.ruby-forum.com/t/nested-resource/193280>\
**Category:** Rails\
**Created:** [August 14, 2010, 5:32pm UTC](https://www.ruby-forum.com/t/nested-resource/193280 "2010-08-14T17:32:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![swengineer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/97f17d/32.png) [@swengineer](https://www.ruby-forum.com/u/swengineer)\
**Post date:** [August 14, 2010, 5:32pm UTC](https://www.ruby-forum.com/t/nested-resource/193280/1 "2010-08-14T17:32:32Z")

</div>

At: [Getting Started with Rails — Ruby on Rails Guides](http://edgeguides.rubyonrails.org/getting_started.html)

Under: 7.3 Adding a Route for Comments

For the following:

resources :posts do  
resources :comments  
end

It says:

This creates comments as a nested resource within posts. This is another  
part of capturing the hierarchical relationship that exists between  
posts and comments.

Does this mean that we made resources :comments nested in resources  
:posts based on the model relationship?

What is we just listed resources :comments without nesting?

Thanks.

---

<div class="post-metadata">

**Author:** ![swengineer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/97f17d/32.png) [@swengineer](https://www.ruby-forum.com/u/swengineer)\
**Post date:** [August 14, 2010, 7:47pm UTC](https://www.ruby-forum.com/t/nested-resource/193280/2 "2010-08-14T19:47:22Z")

</div>

> Does this mean that we made resources :comments nested in resources  
> :posts based on the model relationship?  
> yes

Please read section 2.7 of

> **[Rails Routing from the Outside In — Ruby on Rails Guides](https://edgeguides.rubyonrails.org/routing.html)**
>
> Rails Routing from the Outside InThis guide covers the user-facing features of Rails routing.After reading this guide, you will know: How to interpret the code in config/routes.rb. How to construct your own routes, using either the preferred...

Sijo

---

<div class="post-metadata">

**Author:** ![swengineer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/97f17d/32.png) [@swengineer](https://www.ruby-forum.com/u/swengineer)\
**Post date:** [August 14, 2010, 9:45pm UTC](https://www.ruby-forum.com/t/nested-resource/193280/3 "2010-08-14T21:45:54Z")

</div>

Sijo k g wrote:

> > Does this mean that we made resources :comments nested in resources  
> > :posts based on the model relationship?  
> > yes
> 
> Please read section 2.7 of  
> [Rails Routing from the Outside In — Ruby on Rails Guides](http://edgeguides.rubyonrails.org/routing.html)
> 
> Sijo

Thanks Sijo.
