Ruby on rails 当我用REFINER实现ruby on rails时出错

Ruby on rails 当我用REFINER实现ruby on rails时出错,ruby-on-rails,ruby,html,ruby-on-rails-3,refinery,Ruby On Rails,Ruby,Html,Ruby On Rails 3,Refinery,我正试图用refinery实现ruby on rails入门博客,当我想写评论时,它会说: NoMethodError in CommentsController#create undefined method `permit' for {"commenter"=>"lkjlkm", "body"=>",knm,m"}:ActiveSupport::HashWithIndifferentAccess Rails.root: C:/Sites/blog2 Application T

我正试图用refinery实现ruby on rails入门博客,当我想写评论时,它会说:

NoMethodError in CommentsController#create

undefined method `permit' for {"commenter"=>"lkjlkm", "body"=>",knm,m"}:ActiveSupport::HashWithIndifferentAccess
Rails.root: C:/Sites/blog2

Application Trace | Framework Trace | Full Trace
app/controllers/comments_controller.rb:8:in `create'
Request

Parameters:

{"utf8"=>"✓",
 "authenticity_token"=>"rh9Kq6QxfXuZxlM9nFvsAjxiA5UnueEFKJ3ypcKy3xQ=",
 "comment"=>{"commenter"=>"lkjlkm",
 "body"=>",
knm,
m"},
 "commit"=>"Create Comment",
 "post_id"=>"5"}
Show session dump

Show env dump

Response

Headers:

None
我对控制器代码的意见是:

 class CommentsController < ApplicationController

http_basic_authenticate_with name: "antonio", password: "opening", only: :destroy

def create
@post = Post.find(params[:post_id])

@comment = @post.comments.create(params[:comment].permit(:commenter, :body))
redirect_to post_path(@post)
end

def destroy
@post = Post.find(params[:post_id])
@comment = @post.comments.find(params[:id])
@comment.destroy
redirect_to post_path(@post)
end

end
我希望你能尽快回答
谢谢大家

最好的方法是将它定义为这样一个私有方法

@comment = @post.comments.create(comment_params)

private

def comment_params

   params.require(:comment).permit(:commenter, :body)

end

非常感谢,但现在我有另一个错误:CommentsControllercreate中的TypeError无法将符号转换为String@user3510761引用此行@comment=@post.comments.createparams.require:comment.permit:commenter,:body时出错?@user3510761可能是错误代码。请使用私有方法重试