I'm currently refactoring my rails app. The tricky part so far is the table posts
.
In the current version I'm using posts
for:
- questions
- answers
- comments
Using the post_type
attribute.
Relationships:
- Questions have many answers and comments.
- Answers have many comments.
- Answer belongs to a question.
- Comment belongs to either an answer or a question.
So far I was splitting the question and answer post types into seperate models, using the same table: posts
. But with comments I have the following problem:
Every Post, but comments, is commentable. Would it be a good idea to create an additional comments
table and create a polymorphic association 'commentable' to each of the post types instead of inheriting the posts table?