私は、多くの ActiveRecord モデルがそれに関連付けられた会話を持つことができるプロジェクトに取り組んでいます。ユーザーは、サイトのほぼすべての側面について話し合うことができます。これをどのように実装するかについて、2 つの考えがあります。
1) 会話ではなくアセット内で belongs_to を使用します - 会話はそのアセットをまったく認識しません
class Product< ActiveRecord::Base
belongs_to :conversation
end
class PurchaseOrder < ActiveRecord::Base
belongs_to :conversation
end
2) 会話で belongs_to, :polymorphic => true を使用する
class Conversation < ActiveRecord::Base
belongs_to :asset, :polymorphic => true
end
class Product < ActiveRecord::Base
has_one :conversation, :as => :asset
end
class PurchaseOrder < ActiveRecord::Base
has_one :conversation, :as => :asset
end
この関係をモデル化する正しい方法はどれですか? その関係を一言で表すならば、「商品・発注書の会話は一つかもしれません」。