123456789_123456789_123456789_123456789_123456789_

Exception: ActiveModel::UnknownAttributeError

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, NoMethodError
Instance Chain:
self, NoMethodError
Inherits: NoMethodError
  • ::Object
Defined in: activemodel/lib/active_model/errors.rb

Overview

Raised when unknown attributes are supplied via mass assignment.

class Person
  include ActiveModel::AttributeAssignment
  include ActiveModel::Validations
end

person = Person.new
person.assign_attributes(name: 'Gorby')
# => ActiveModel::UnknownAttributeError: unknown attribute 'name' for Person.

Class Method Summary

Instance Attribute Summary

Constructor Details

.new(record, attribute) ⇒ UnknownAttributeError

[ 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

Instance Attribute Details

#attribute (readonly)

[ GitHub ]

  
# File 'activemodel/lib/active_model/errors.rb', line 539

attr_reader :record, :attribute

#record (readonly)

[ GitHub ]

  
# File 'activemodel/lib/active_model/errors.rb', line 539

attr_reader :record, :attribute