1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
class Subscription
  has_many :subscription_items
  has_many :subscribables, :through => subscription_items
end

class SubscriptionItem
  belongs_to :subscription
  belongs_to :subscribable, :polymorphic => true
end

class XProduct
  has_many :subscription_items, :as => :subscribable
end

class YProduct
  has_many :subscription_items, :as => :subscribable
end