Active Model UnknownAttributeError
当通过批量赋值提供未知属性时引发异常。
class Person
include ActiveModel::AttributeAssignment
include ActiveModel::Validations
end
person = Person.new
person.assign_attributes(name: 'Gorby')
# => ActiveModel::UnknownAttributeError: unknown attribute 'name' for Person.
方法
- N
属性
[R] | attribute | |
[R] | record |
类公共方法
new(record, attribute) 链接
源代码: 显示 | 在 GitHub 上
# File activemodel/lib/active_model/errors.rb, line 541 def initialize(record, attribute) @record = record @attribute = attribute super("unknown attribute '#{attribute}' for #{@record.class}.") end