0
我有一個模型只能在活動管理員中創建。我有以下控制器設置:Active Admin內的ActiveModel :: ForbiddenAttributesError
def index
@events = Event.all
end
def new
@event = Event.new
end
def create
@event = Event.new(event_params)
末
private
def event_params
params.require(:event).permit(:venue, :trainer_id, :description, :training_request_id, :title, :date)
end
end
我的事件模型:
class Event < ActiveRecord::Base
has_one :trainer, inverse_of: :events
belongs_to :training_request, inverse_of: :event
delegate :module, to: :training_request
end
所有領域都存在,但我不能明白爲什麼它拋出這個錯誤。
這裏是從錯誤的輸出:
Parameters:
{"utf8"=>"✓",
"authenticity_token"=>"H0sdhO3JsWBb8tYvFm52YvGsVvcnArigaVD+1r5HzL8=",
"event"=>{"training_request_id"=>"3",
"venue"=>"this is a venue",
"description"=>"this is a descripton",
"title"=>"event title",
"date(1i)"=>"2018",
"date(2i)"=>"3",
"date(3i)"=>"5",
"date(4i)"=>"05",
"date(5i)"=>"00",
"commit"=>"Create Event"}
任何人有爲什麼發生這種情況的任何想法?
值得一提的是,在軌道控制檯內,它可以很好地保存。