私はバックボーンを使用していて、新しいオブジェクトを作成しようとしていますが、このエラーが発生しています。レールは気にしない属性を無視すると思った。つまり、本物のトークンが自分のオブジェクトに追加しようとしていません。バックボーン/レール - ビルド(params [...])ActiveRecord :: UnknownAttributeErrorを発生させます
マイコントローラ:
def create
page = Page.find(params[:page_id])
branch = page.page_branches.build(params[:page_branch])
branch.form = page.form
if branch.valid?
page.page_branches << branch
redirect_to(edit_page_path(page, :anchor => "branch-panel"))
else
raise "#{branch.errors.map}"
end
end
エラー:以下の応答へ
Processing by PageBranchesController#create as JSON
Parameters: {"page_branch"=>{"next_page_id"=>"KS5ad82889e04e5806e0455d5a81e81a9511",
"description"=>"linking", "utf8"=>"", "authenticity_token"=>"", "id"=>nil,
"page_id"=>"KS000c29724a16-u-2TQMP57-gYm-U", "trigger_type"=>"Always",
"base_options"=>"AllowAnonymous;BASE",
"question_options"=>"KS000c29724a16CfC2TQUL1--gxG-U", "keyword_options"=>"",
"qualification"=>"", "commit"=>""}, "page_id"=>"KS000c29724a16-u-2TQMP57-gYm-U"}
WARNING: Can't mass-assign protected attributes: id
Completed 500 Internal Server Error in 239ms
ActiveRecord::UnknownAttributeError (unknown attribute: utf8):
app/controllers/page_branches_controller.rb:21:in `create'
ありがとう:
は、私は私のレールのモデルにattr_accessibleを追加しました:
attr_accessible :page_id, :page_name, :next_page_id, :next_page_name,
:description, :trigger_type, :internal_qualification,
:order, :form_id, :qualification
そうすることでで、私は次の警告を得るが、ビルドが提供されるつもりハッシュの全てのキー/値のペアを使用しようとされて
WARNING: Can't mass-assign protected attributes: utf8, authenticity_token, id, base_options, question_options, keyword_options, commit