跳到內容 跳到搜尋

Active Model ForbiddenAttributesError

當大量指定使用禁止屬性時會引發。

class Person < ActiveRecord::Base
end

params = ActionController::Parameters.new(name: 'Bob')
Person.new(params)
# => ActiveModel::ForbiddenAttributesError

params.permit!
Person.new(params)
# => #<Person id: nil, name: "Bob">