cant access nested ressource 'comments' in rails 3.0.1

Posted by DannyRe on Stack Overflow See other posts from Stack Overflow or by DannyRe
Published on 2011-01-02T13:25:21Z Indexed on 2011/01/02 13:54 UTC
Read the original article Hit count: 323

Hey,

I hope you can help me.

/config/routes.rb

resources :deadlines do
resources :comments
end

/model/comment.rb

class Comment < ActiveRecord::Base

belongs_to :post, :class_name => "Post", :foreign_key => "post_id"

end

/model/post.rb

class Post < ActiveRecord::Base

has_many :comments

end

When I want to visit: http://localhost:3000/posts/1/comments/new

it says: undefined method `comments_path' for #<#:0x4887138> in _form.html

I use 'formtastic' and the _form.html.erb looks like this:

<% semantic_form_for [@comment] do |form| %>
<% form.inputs do %>
<%= form.input :content %>
<% end %>

<% form.buttons do %>
<%= form.commit_button %>
<% end %>
<% end %>

© Stack Overflow or respective owner

Related posts about routes

Related posts about ruby-on-rails3