instance method
[]=
Ruby on Rails 8.0.4
Since v4.0.13Signature
[]=(attr_name, value)
Updates the attribute identified by attr_name using the specified value. The attribute value will be type cast upon being read.
class Person < ActiveRecord::Base end person = Person.new person[:date_of_birth] = "2004-12-12" person[:date_of_birth] # => Date.new(2004, 12, 12)
Parameters
-
attr_namereq -
valuereq
Source
# File activerecord/lib/active_record/attribute_methods.rb, line 428
def []=(attr_name, value)
write_attribute(attr_name, value)
end
Defined in activerecord/lib/active_record/attribute_methods.rb line 428
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::AttributeMethods