I am working on a project where many ActiveRecord models can have a conversation associated with it. Users can discuss just about every aspect of the site. I have two ideas as to how this should be implemented.
1) Use a belongs_to in the asset, not the conversation - conversation will be totally unaware of its asset
class Product< ActiveRecord::Base
belongs_to :conversation
end
class PurchaseOrder < ActiveRecord::Base
belongs_to :conversation
end
2) Use a belongs_to, :polymorphic => true in the conversation
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
Which is the correct way to model this relationship? If I were to state the relationship, I would say that "a product / purchase order may have one conversation".