あなたが私を助けてくれることを願っています。
/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
私が訪問したいとき、私http://localhost:3000/posts/1/comments/new
は得ます:
undefined method `comments_path' for #<#<Class:0x4889d18>:0x4887138> in _form.html
私は「formtastic」を使用し、the _form.html.erb
次のようになります。
<% semantic_form_for [@comment] do |form| %>
<% form.inputs do %>
<%= form.input :content %>
<% end %>
<% form.buttons do %>
<%= form.commit_button %>
<% end %>
<% end %>