With Active Record, we can access a value like
user = User.find(1)
user.name #=> 'John'
user[:name] #=> 'John'
Rails convention is to use ActiveRecord::AttributeMethods::Read#
read_attribute (dot notation), rather than its alias ActiveRecord::AttributeMethods#
Returns the value of the attribute identified by
attr_nameafter 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::MissingAttributeErrorif the identified attribute is missing.