Reputation: 21
I'm coding my first Ruby On Rails app and I have my first design issue. The main idea is to build a very easy app that shows a list of Post (such posts could be simply text, video or a picture). In addition, a Post could be a "feed" from different apps such as Twitter, Facebook or simply added by means a form inside the app. In conclusion, I have posts posted by other apps and these post could be text, video or simply images.
My concern is the inheritance. Should I use Polymorphic models? This way I could manage the fact that a Post could be text, video or a picture. With respect to the apps that a Post could come from, I think that I would use a field indicating this.
Any better ideas?
Thank you.
Upvotes: 1
Views: 51
Reputation: 1789
Since this is your first app don't worry too much about design issues. Can a post contain only one of text, video, or picture? Or can it have any combination of the three?
If the latter, I would just use one model. If you're sure that it's the former then go for the polymorphic models.
Right or wrong, you'll learn from the exercise. Sometimes it's just important to take that first step.
Upvotes: 1