instance method
[]=
Ruby on Rails 6.0.6
Since v4.0.13Signature
[]=(attr_name, value)
Updates the attribute identified by attr_name with the specified value. (Alias for the protected #write_attribute method).
class Person < ActiveRecord::Base end person = Person.new person[:age] = '22' person[:age] # => 22 person[:age].class # => Integer
Parameters
-
attr_namereq -
valuereq
Source
# File activerecord/lib/active_record/attribute_methods.rb, line 336
def []=(attr_name, value)
write_attribute(attr_name, value)
end
Defined in activerecord/lib/active_record/attribute_methods.rb line 336
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::AttributeMethods