class Subscription < ApplicationRecord
belongs_to :subscribable, polymorphic: true
belongs_to :user
end
class Podcast < ApplicationRecord
has_many :subscriptions, as: :subscribable
has_many :users, through: :subscriptions
end
class Newspaper < ApplicationRecord
has_many :subscriptions, as: :subscribable
has_many :users, through: :subscriptions
end
class User < ApplicationRecord
has_many :subscriptions
has_many :podcasts, through: :subscriptions, source: :subscribable, source_type: 'Podcast'
has_many :newspapers, through: :subscriptions, source: :subscribable, source_type: 'Newspaper'
end