Ruby on rails rails 5嵌套资源删除

Ruby on rails rails 5嵌套资源删除,ruby-on-rails,nested-resources,Ruby On Rails,Nested Resources,我正在尝试删除注释,它是Post对象的嵌套资源 我收到这个消息: ActionController::CommentsController中的参数丢失#销毁参数 缺少或值为空:注释 提取源: def comments_params ActionController::Parameters.permit_all_parameters = true params.required(:comment).permit(:author,:body) end 代码如下: def destroy

我正在尝试删除
注释
,它是
Post
对象的嵌套资源

我收到这个消息:

ActionController::CommentsController中的参数丢失#销毁参数 缺少或值为空:注释

提取源:

def comments_params
  ActionController::Parameters.permit_all_parameters = true
  params.required(:comment).permit(:author,:body)
end
代码如下:

def destroy
    @comment.destroy
end

def comments_params
  ActionController::Parameters.permit_all_parameters = true
  params.required(:comment).permit(:author,:body)
end
在视图中(从
post
show.html.erb
调用的部分
\u comment.html.erb
):


请求参数为:

{u方法=>“删除”, “真实性令牌”=>“XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX”, “post_id”=>“test-2”、“id”=>“3”}

我试图在
comments\u param
方法中添加不同的参数,但这无助于解决问题


在找到评论之后,然后在销毁特定评论之后,谢谢

    before_filter :find_comment, :only => [:destroy]

    def destroy
      @comment.destroy
    end

    def find_comment
      @comment = Comment.get(params[:id])
    end

    private

    def comments_params
      params.required(:comment).permit(:author,:body)
    end

这看起来像是一个有效的post_id吗?“post_id”=>“test-2”post_id是因为友好的_id gem,即使post_id等于“2”,也会出现相同的结果。
    before_filter :find_comment, :only => [:destroy]

    def destroy
      @comment.destroy
    end

    def find_comment
      @comment = Comment.get(params[:id])
    end

    private

    def comments_params
      params.required(:comment).permit(:author,:body)
    end