I have a couple of models in my system:
- User Reputation
- Post Reputation
- Response Reputation
(similar to SO).
So, they are share some basic code:
- Incrementing and decrementing values
- a unique_id belonging to the three object that the reputation represents (User, Post, Response)
If there were C++, I would have a superclass called "Reputation
" that would encapsulate these concepts.
Currently, I have three models, separately defined but as I build the system I'm starting to realize there is a lot of code duplication,etc.
If I were to use STI then I would have to a owner_id
field which would be the object_id and a owner_type
.
So, what's the best way of the handling this case?