Check whether a getter is an attribute or an association

Sometimes you might want to know if an attribute is an associated object or a simple string, integer etc. You can use the reflect_on_association Show archive.org snapshot method for that.

if Person.reflect_on_association(:address)
  Person.address.attributes # do something
else
  Person.address # do something else
end
Dominik Schöler