【发布时间】:2015-11-02 13:08:11
【问题描述】:
我的代码有些问题。你能帮帮我吗?
views/topics/show.html.slim
- if current_user == post.user
= link_to 'Удалить комментарий',forum_topic_post_path(@forum, @topics, @posts, @post),
method: :delete,
data: { confirm: 'Are you sure?' }
控制器/post_controller.rb
def destroy
@forum = Forum.find params[:forum_id]
@topic = Topic.find params[:topic_id]
@post.user = current_user
@post = Post.find(params[:id]).destroy
end
错误:
ActiveRecord::RecordNotFound in PostsController#destroy
找不到 'id'=# 的帖子
@post = Post.find(params[:id]).destroy
【问题讨论】:
标签: ruby-on-rails controller nested destroy