【发布时间】:2014-03-08 04:53:09
【问题描述】:
我在“@comment = @post.cmets.build(params[:comment])”中得到一个“ActiveModel::ForbiddenAttributesError in CommentsController#create”和高亮显示
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 action: 'show', status: :created, location: @comment }
else
format.html { render action: 'new' }
format.json { render json: @comment.errors, status: :unprocessable_entity }
end
end
end
在教程视频中,编码员将其放入并完美运行,但当我发布此视频时,它会出错。我检查了代码,似乎看不出有什么问题。提前致谢!
【问题讨论】:
标签: ruby-on-rails ruby params