Forum: Ruby on Rails Using form_for and has_many associations with a controller in its own subdirectory

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Matt W. (Guest)
on 2009-02-27 11:18
(Received via mailing list)
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 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!
This topic is locked and can not be replied to.