Reputation: 2495
I have a Comment model in my app with many comment_types
class Comment < ActiveRecord::Base
belongs_to :comment_type, :polymorphic => true
end
Also I have a public QA system. So for every pair I have a model
class QA < ActiveRecord::Base
has_one :question, :class_name => :comment, :as => :comment_type, :autosave => true
has_one :asnwer, :class_name => :comment, :as => :comment_type, :autosave => true
end
And this seems a little overuse for me to have a special table for QA model. Because this table should have only ID key. So is there a better solution? Or maybe something wrong with my architecture in total?
Upvotes: 0
Views: 1146
Reputation: 6612
Why a QA model? I would do with a Question has_many Answers and an question has_many Comments. And optionally you could say an Answer also has_many Comments, if you want users to be able to comment on other comments. Much easier I think.
Upvotes: 1