Exception: ActiveModel::UnknownAttributeError

Inherits:
NoMethodError
  • Object
show all
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activemodel-7.0.4/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.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(record, attribute) ⇒ UnknownAttributeError

Returns a new instance of UnknownAttributeError.



510
511
512
513
514
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activemodel-7.0.4/lib/active_model/errors.rb', line 510

def initialize(record, attribute)
  @record = record
  @attribute = attribute
  super("unknown attribute '#{attribute}' for #{@record.class}.")
end

Instance Attribute Details

#attributeObject (readonly)

Returns the value of attribute attribute.



508
509
510
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activemodel-7.0.4/lib/active_model/errors.rb', line 508

def attribute
  @attribute
end

#recordObject (readonly)

Returns the value of attribute record.



508
509
510
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activemodel-7.0.4/lib/active_model/errors.rb', line 508

def record
  @record
end