Rafał Jaroszewicz

Using attr_accessor to clean up your calls between models

In my glorious real estate management app I thought that it’d be cool to know how much rent a tenant has to pay without typing tenant.flat.rent every single time (tenant belongs_to :flat)

So instead, we can just use attr_accessor :rent as below.

Now I can always access tenant’s rent by simply going for tenant.rent

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top