STI or Polymorphic approach with this design?
Ive got the following models: User, Video, Event, Photo. These models are separate.
On the other hand, I've got these models: Like, Comment, Attend.
Basically:
- A user can like and comment on a video, event of photo.
- A user can attend an even开发者_StackOverflowt.
Should Like, Comment, Attend follow an STI approach and inherit from another class called Interaction?
Or should I follow a polymorphic approach instead?
If STI, should I be worried that the Interaction model is filling up three times as much from Like, Comment and Attend? Should I be worried that one day this model will be 'overloaded'?
What are your thoughts on this?
I think your case could be solved with polymorphism very well, with 'Likes' being in a polymorphic relationship with Video, Event and Photo. Attend and Event should be separate.
This should help: http://railscasts.com/episodes/154-polymorphic-association
精彩评论