# Nested resource

**URL:** <https://www.ruby-forum.com/t/nested-resource/156713>\
**Category:** Rails\
**Created:** [January 1, 2009, 5:56pm UTC](https://www.ruby-forum.com/t/nested-resource/156713 "2009-01-01T17:56:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 1, 2009, 5:56pm UTC](https://www.ruby-forum.com/t/nested-resource/156713/1 "2009-01-01T17:56:52Z")

</div>

Hi!

I am trying to get this to work: it is really close and half way  
works.

routes:

map.namespace(:admin) do |admin|  
admin.namespace(:products) do |products|  
products.resources :brains,  
:has\_many =\>  
[:pdfs, :images, :firmwares, :specables]  
end  
end

when I run rake routes i get stuff like:

new\_admin\_products\_brain  
edit\_admin\_products\_brain

which is what I expected. however when I try to use this in a form  
like such:

\<% form\_for([:admin, @product]) do |f| %\>

I get an error this error from rails in a from view:

undefined method `admin\_product\_brain\_path’ for #\<ActionView::Base:  
0x20350f0\>

Not sure how to fix this, but this is so freggin close it is  
painful…

Anyone know the answer?

Happy New Year!

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 1, 2009, 5:58pm UTC](https://www.ruby-forum.com/t/nested-resource/156713/2 "2009-01-01T17:58:03Z")

</div>

BTW,

My controller looks like this:

class Admin::Products::BrainsController \< Admin::ProductsController  
end

as these are all just products…  
Hope this makes sense.

On Jan 1, 8:55 am, “removed\_email\_address@domain.invalid” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
