# RESTful routes with :has\_many

**URL:** <https://www.ruby-forum.com/t/restful-routes-with-has-many/148951>\
**Category:** Rails\
**Created:** [September 18, 2008, 3:58pm UTC](https://www.ruby-forum.com/t/restful-routes-with-has-many/148951 "2008-09-18T15:58:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Christoph\_Petschnig](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/90db22/32.png) [@Christoph\_Petschnig](https://www.ruby-forum.com/u/Christoph_Petschnig)\
**Post date:** [September 18, 2008, 3:58pm UTC](https://www.ruby-forum.com/t/restful-routes-with-has-many/148951/1 "2008-09-18T15:58:52Z")

</div>

Hello, I don’t know if this is a bug or a feature. When defining  
routes like:

map.resources :as, :has\_many =\> ‘bs’  
map.resource :b, :has\_many =\> ‘cs’  
map.resource :c

I get:

new\_b\_c GET /b/cs/new {:controller=\>“cs”, :action=\>“new”}

yet I want:

new\_b\_c GET /bs/:b\_id/cs/new {:controller=\>“cs”, :action=\>“new”}

which I get with adding:

map.resources :bs, :has\_many =\> ‘cs’

Is this supposed to be this way?  
Thank you, regards Christoph

---

<div class="post-metadata">

**Author:** ![Christoph\_Petschnig](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/90db22/32.png) [@Christoph\_Petschnig](https://www.ruby-forum.com/u/Christoph_Petschnig)\
**Post date:** [September 18, 2008, 4:19pm UTC](https://www.ruby-forum.com/t/restful-routes-with-has-many/148951/2 "2008-09-18T16:19:28Z")

</div>

On Sep 18, 8:32 am, Christoph\_Petschnig [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> yet I want:
> 
> new\_b\_c GET /bs/:b\_id/cs/new {:controller=\>“cs”, :action=\>“new”}
> 
> which I get with adding:
> 
> map.resources :bs, :has\_many =\> ‘cs’
> 
> Is this supposed to be this way?  
> Thank you, regards Christoph

I think you want to use map.resources, not map.resource, in all of  
those.

Jeff

REST with Rails: $295, Oct 4, Austin, TX:  
[http://www.purpleworkshops.com/workshops/rest-and-web-services](http://www.purpleworkshops.com/workshops/rest-and-web-services)  
Discount code “PWRRGG” =\> 10% off
