ActiveModel::ForbiddenAttributesError - Rails 4

后端 未结 1 806
礼貌的吻别
礼貌的吻别 2021-02-13 15:22

I\'m a bit lost. I an getting the Rails 4 error: ActiveModel::ForbiddenAttributesError. I understand that this means I need to permit items to pass, which I have done, but I mu

1条回答
  •  臣服心动
    2021-02-13 15:42

    Instead of

    @comment = @post.comments.create!(params[:comment])
    

    you want

    @comment = @post.comments.create!(comment_params)
    

    You did all the hard work without using the permitted attributes!

    0 讨论(0)
提交回复
热议问题