My suggestion then is to come up with your classes first and then make a
design. A very common pitfall is to design for something that "may"
happen and then later face over engineered code.. In the late nineties,
we called this the YAGNI principle which stood for "You Aint Going to
If you propose your new more complete class model, I can help with your
polymorphic associations (If you still need them)..
Lastly, remember that PAs are not free, they add extra conditions to the
select clauses which can be quite costly with improper or imcomplete
although I just supplied just three basic models, my application already
contains more than 15 different models that should be linked to each
Some more examples:
- I need a relationship between two documents ("Like: Document B is an
attachment to Document A).
- I need a relationship beween a Key-Class (the ones you use to open a
house and a RealtyItem (name: "Key House-Entrance").
- I need a relationship between two Persons, to model something like
I could supply a dozen more. This is why already now I want a flexible
modelling of these relationships.
I image a table to store the relationships like this:
id name the_one_id the_one_class the_other_id the_other_class
1 Owner 2 Person 3 RealtyItem
2 Assistant 5 Person 5 Person
3 Lease#333 5 Document 3 RealtyItem
It seems so simple - but how do I achieve it correctly using Rails?