How to make a custom getter & setter for an ActiveRecord (Ruby on Rails) model's attributes/properties

7 December 2016
class Person < ActiveRecord::Base

# don't use attr_accessible here as it interferes/duplicates the methods below

# setter
```php
def shirt=(value)
write\_attribute(:shirt_fee_in_cents, value)
end

# getter
def shirt
if self[:shirt].present?
return self[:shirt]
end
AverageHuman.default_shirt
end