Rails Mixin: Auto-instantiated Associations
Often times you have an association that you want to be available as soon as you access it. That is, given a User
model that has_one :location
, you want to call user.location.country
without worrying about whether user.location
has been instantiated.