I am creating a blog using ruby on rails. I am following a tutorial that is using an older version on rails. I am trying to post comments about the blog post on the same page. whenever i hit the submit button i get this error message. ActiveModel::ForbiddenAttributesError
Extracted source (around line #44):
def create
@post = Post.find(params[:post_id])
@comment= @post.comments.new(params[:comment])
respond_to do |format|
if @comment.save
Here is my code inside my controller
def create
@post = Post.find(params[:post_id])
@comment= @post.comments.build(params[:comment])
respond_to do |format|
if @comment.save
format.html { redirect_to @post, notice: 'Comment was successfully created.' }
format.json { render json: @post, status: :created, location: @comment }
else
format.html { render action: "new" }
format.json { render json: @post.errors, status: :unprocessable_entity }
end
end
Thanks for the help