嗨,伙计们,显然每个新来的人都知道并且对糟糕的文档感到愤怒
acts_as_commentable_with_threading
提供 - 我也不例外。
我有一个 Post 模型,我已经成功了
acts_as_commentable
按照文档中的要求。此外,我在帖子的 show 方法中添加了所需的代码。哪个是:
def show
@post = Post.find(params[:id])
@comments = @post.comment_threads.order('created_at desc')
@new_comment = Comment.build_from(@post, current_user, "")
end
在节目中我有:
<%= form_for @new_comment do |f| %>
<%= f.label :body, 'Comment' %>
<%= f.text_area :body %>
<%= f.submit 'Post comment' %>
<% end %>
现在显然我意识到我需要在comments_controller 中有一个创建操作。但是我不知道要写什么才能成功保存评论。有什么帮助吗?