If you have a property named balance in a model object, you can get the value of the property by using the index operator, you can use a string or tag, where we use the tag, for example:
Account[:balance] #=> Get value
Account[:balance] = 0.0 #=> Set Value
But this common code is discouraged, and better yet, using Ruby's Access method:
Account.balance #=> Get Value
account.balance = 0.0 #=> Set Value
Here, we use two methods to get the value of the property, the Active record will do the appropriate type conversion, for example, if the column in the database is a timestamp (TimeStamp), then we will get a time object, if you want the original value of the attribute, add _ Before_type_cast to the end of the access method, for example:
Account.balance_before_type_cast #=> "123.4", a string
Account.release_date_before_type_cast #=> "20050301"
Finally, you can also use the model's own private method Read_attribute and Write_attribute, which use the property name as an argument.