I'm stuck in a weird design issue,
I am working on two types of profiles. Models
- User Profile (owned by the User)
- others that are supported locally as โbotsโ (do not belong to anyone).
The typical OO behavior of these two types of profiles is the same, but only important attributes / properties are common (very important of them are 5-6), other properties, such as "interests, etc." (almost 10-15 properties) does not exist for bot profiles
The coder that worked on this earlier created separate models / controllers for bot profiles / user profiles that create a lot of redundancy everywhere, and as expected, it's hard to maintain, write tests, etc. I wanted to DRY this, at least solve some / all of these redundancy problems.
Someone suggested single-page inheritance as a solution
Someone suggested using polymorphic associations.
What a better approach. When do we really use STI?
My own thought was STI is best used when the attributes are the same for the models and they differ in behavior.
Thoughts on what I can do?
inheritance ruby-on-rails
Rishav Rastogi Feb 17 '09 at 6:02 2009-02-17 06:02
source share