# Using form\_for and has\_many associations with a controller in its own subdirectory

**URL:** <https://www.ruby-forum.com/t/using-form-for-and-has-many-associations-with-a-controller-in-its-own-subdirectory/161553>\
**Category:** Rails\
**Created:** [February 27, 2009, 10:18am UTC](https://www.ruby-forum.com/t/using-form-for-and-has-many-associations-with-a-controller-in-its-own-subdirectory/161553 "2009-02-27T10:18:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mwalsh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/91b2a8/32.png) [@mwalsh](https://www.ruby-forum.com/u/mwalsh)\
**Post date:** [February 27, 2009, 10:18am UTC](https://www.ruby-forum.com/t/using-form-for-and-has-many-associations-with-a-controller-in-its-own-subdirectory/161553/1 "2009-02-27T10:18:55Z")

</div>

Hi,

I’m trying to create a Blog in it’s own subdirectory for an E-commerce  
site. Everything is hooked up just fine for the basic posting, but  
when I try to add Comments, I’m getting all sorts of headaches! I’m  
referring to the screencast by Ryan B. on the [rubyonrails.org](http://rubyonrails.org) site.

Basically, my controller is Blog::Comments, in my Blog::Post comment  
form I have this line:

\<% form\_for [@post, Blog::Comment.new] do |f| %\>

Which throws this error:

undefined method `blog\_post\_blog\_comments\_path’ for #\<ActionView::Base:  
0x25ad3fc\>

The path that I think I need is 'blog\_post\_comments\_path", and I’m not  
sure if this is a routing issue or something else?

Or, if I try this line:

\<% form\_for [@post, :Comment.new] do |f| %\>

I get this error:

uninitialized constant ActionView::Base::CompiledTemplates::Comment

I’m guessing it couldn’t find the Comment Controller because it is  
actually Blog::Comment

Currently, I have this in my routes file:

map.namespace :blog do |blog|  
blog.resources :posts, :has\_many =\> :comments  
end

Any advice would be greatly appreciated, thanks!
