我为 ActiveAdmin 启用了许多模型,即它们以默认行为向 ActiveAdmin 注册并且运行良好。
当我生成新模型和关联的 active_admin 资源时,它显示以下错误
rails g model log body:text
rails g active_admin:resource log
rake db:migrate
然后尝试从管理界面创建新的日志记录,它显示以下错误
ActiveModel::MassAssignmentSecurity::Error in Admin::LogsController#create
Can't mass-assign protected attributes: body
Rails.root: /Users/amitamb/sdtexty
Application Trace | Framework Trace | Full Trace
Request
Parameters:
{"utf8"=>"✓",
"authenticity_token"=>"wpTnR0B8qLphaxAyp/G9EuA4Gw+gZpwrdNjcYwvd3YY=",
"log"=>{"body"=>"af"},
"commit"=>"Create Log"}
Show session dump
Show env dump
Response
Headers:
None
注意:日志模型中存在 attr_accessible :body