Wouldn’t that be more reasonably described as an ‘Employee’ ‘has_one’ or
Yes, except that would (pre 1.1) force you have a single ‘Employee’
class, or use STI to hack the subclasses.
After all, people can change role or have many of them. I doubt you will
want to have a EmployeJanitorManagerWorker lurking in your class
Well, to be fair, they can only switch roles, or have many roles if I
say they can, as this is my app
Hmm, my example is doing what languages like Java do, mixing
Polymorphism with Inheritance. Perhaps a better examples is the one
from Chad’s Rails Recipes.
Say we have an Address. a Person can have an Address, or a Company can
have an address. Person and Company are entirely different concepts,
sharing no attributes or functionality other than that they both has_one
:address. WHat to put in the Address side ?
We could have has_many :people AND has_many :companies but that makes it
hard to do something across all things at this address.
With Polymorphic associations we can say that an Address belongs_to
For a fuller working, and much, much clearer explanations(of this and
other 1.1 features), run, don’t walk to the PragBookshelf site and buy