lundi 3 octobre 2016

ActiveModel::ForbiddenAttributesError when tried to add new comment

I have following code in app/controllers/comments_controller.rb

class CommentsController < ApplicationController
  def create
    book = Book.find params[:book_id]
    comment = book.comments.new params[:comment]
    comment.save
    flash[:notice] = 'Comment saved'
    redirect_to book_path(book)     
  end
end

I am not sure why i am getting error at line comment = book.comments.new params[:comment]

Aucun commentaire:

Enregistrer un commentaire