[]=

[]=(attr_name, value) Instance Public methods 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

[]

[](attr_name) Instance Public methods Returns the value of the attribute identified by attr_name after it has been typecast (for example, â2004-12-12â in a date column is cast to a date object, like Date.new(2004, 12, 12)). It raises ActiveModel::MissingAttributeError if the identified attribute is missing. Alias for the read_attribute method. class Person < ActiveRecord::Base belongs_to :organization end person = Person.new(name: 'Francesco', age: '22') person[:name] # =>

write_attribute

write_attribute(attr_name, value) Instance Public methods Updates the attribute identified by attr_name with the specified value. Empty strings for fixnum and float columns are turned into nil.

raw_write_attribute

raw_write_attribute(attr_name, value) Instance Public methods

define_method_attribute=

define_method_attribute=(name) Instance Protected methods See define_method_attribute in read.rb for an explanation of this code.

define_method_attribute=

define_method_attribute=(attr_name) Instance Protected methods Defined for all datetime and timestamp attributes when time_zone_aware_attributes are enabled. This enhanced write method will automatically convert the time passed to it to the zone stored in Time.zone.

serialized_attributes

serialized_attributes Instance Public methods Returns a hash of all the attributes that have been specified for serialization as keys and their class restriction as values.

serialize

serialize(attr_name, class_name_or_coder = Object) Instance Public methods If you have an attribute that needs to be saved to the database as an object, and retrieved as the same object, then specify the name of that attribute using this method and it will be handled automatically. The serialization is done through YAML. If class_name is specified, the serialized object must be of that class on retrieval or SerializationTypeMismatch will be raised. A notable side effect of serializ

read_attribute

read_attribute(attr_name) Instance Public methods Returns the value of the attribute identified by attr_name after it has been typecast (for example, â2004-12-12â in a date column is cast to a date object, like Date.new(2004, 12, 12)).

define_method_attribute

define_method_attribute(name) Instance Protected methods