0
我正在rails上使用ruby創建一個博客。我正在使用在rails上使用較舊版本的教程。我正在嘗試在同一頁面上發佈關於博客文章的評論。每當我點擊提交按鈕時,我都會收到此錯誤消息。 ::加載ActiveModel ForbiddenAttributesError使用老版本的紅寶石的ActiveModel :: ForbiddenAttributesError?
提取的源(左右線#44):
def create
@post = Post.find(params[:post_id])
@comment= @post.comments.new(params[:comment])
respond_to do |format|
if @comment.save
這是我我的控制器內的代碼
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
感謝您的幫助
,你能否告訴comment.rb文件的線,說:'attr_asseccible',還發布表單代碼。 – Surya 2014-11-24 05:25:32