instance method
[]=
Ruby on Rails 4.1.16
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] # => Fixnum
Parameters
-
attr_namereq -
valuereq
Source
# File activerecord/lib/active_record/attribute_methods.rb, line 396
def []=(attr_name, value)
write_attribute(attr_name, value)
end
Defined in activerecord/lib/active_record/attribute_methods.rb line 396
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::AttributeMethods