ActiveModel::禁止使用旧版本的ruby进行属性错误?

ActiveModel::禁止使用旧版本的ruby进行属性错误?,ruby,ruby-on-rails-4,ruby-on-rails-3.2,Ruby,Ruby On Rails 4,Ruby On Rails 3.2,我正在使用RubyonRails创建一个博客。我正在学习一个在rails上使用旧版本的教程。我试着在同一页上发表关于博客文章的评论。每当我点击submit按钮时,就会收到此错误消息。 ActiveModel::禁止属性错误 提取的源(第44行附近): 这是我控制器中的代码 def create @post = Post.find(params[:post_id]) @comment= @post.comments.build(params[:comment]) respond_to

我正在使用RubyonRails创建一个博客。我正在学习一个在rails上使用旧版本的教程。我试着在同一页上发表关于博客文章的评论。每当我点击submit按钮时,就会收到此错误消息。 ActiveModel::禁止属性错误

提取的源(第44行附近):

这是我控制器中的代码

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

谢谢您的帮助

我想您正在使用Rails 4。如果是这样,所需的参数必须在控制器中标记为所需


您可以参考
http://stackoverflow.com/questions/17868427/rails-4-activemodelforbiddenattributeserror

您能否显示comment.rb文件的行,该行显示:
attr\u assecible
,同时发布表单代码。
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