# RESTful Resources and Sub-Resources

**URL:** <https://www.ruby-forum.com/t/restful-resources-and-sub-resources/135391>\
**Category:** Rails\
**Created:** [April 21, 2008, 8:26pm UTC](https://www.ruby-forum.com/t/restful-resources-and-sub-resources/135391 "2008-04-21T20:26:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sw0rdfish](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/edb3f5/32.png) [@sw0rdfish](https://www.ruby-forum.com/u/sw0rdfish)\
**Post date:** [April 21, 2008, 8:26pm UTC](https://www.ruby-forum.com/t/restful-resources-and-sub-resources/135391/1 "2008-04-21T20:26:23Z")

</div>

Quick question I’m hoping you guys might know…

I’m working at re-factoring my application to be RESTful and I’m  
running into a lot of problems as I try to totally understand this  
whole REST thing… my question here however is with the routes.rb  
file… for example I have Clients, who have Locations… so would  
the code in the routes.rb file be

map.resources :clients, :has\_many =\> [:locations]

or I’ve seen this as well…

map.resources :clients do |clients|  
clients.resources :locations  
end

Which of these is the correct Rails 2.0 way of doing it?

Thanks in advanced.

---

<div class="post-metadata">

**Author:** ![sw0rdfish](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/edb3f5/32.png) [@sw0rdfish](https://www.ruby-forum.com/u/sw0rdfish)\
**Post date:** [April 21, 2008, 8:48pm UTC](https://www.ruby-forum.com/t/restful-resources-and-sub-resources/135391/2 "2008-04-21T20:48:22Z")

</div>

> Which of these is the correct Rails 2.0 way of doing it?

As far as I know both are valid, just the former being a shorthand for  
default cases and the latter allowing for advanced configuration  
parameters such as custom methods.

Cheers,  
Jan
