Classy
Inheritancehttp://stonean.com/wiki/classy-inheritance/Classy-inheritanceprovides
two ActiveRecord methods: depends_on and can_be.
Depends_on allows you define another model for which the calling model
requires. A common setup for this is User → Profile, where
User.depends_on
:profile, :attrs => [:first_name, :last_name, :email]
This will add pass through methods so you can access the profile
attributes
define via the @user object: @user.first_name. This also means you can
do
@user.first_name = “Andrew”. So, your view can be cleaned up by
removing
any calls/usage of the Profile class/object. Classy inheritance will
validate and save the requisite object. You will also get a
User.find_with_profile method that will automatically do the :include =>
:profile for you.
It also supports polymorphic associations (was actually the reason it
was
created). Please check out the site
documentationhttp://stonean.com/wiki/classy-inheritance/Classy-inheritancefor
more details.
By the way, Classy Inheritance was written to use the methods exposed to
developers such as belongs_to, validates_associated and so forth in
order
to avoid monkey patching the ActiveRecord code.
thanks,
andy
Andrew S.