BigW Consortium Gitlab

subscription.rb 541 Bytes
Newer Older
Valery Sizov committed
1 2 3 4 5 6 7 8 9 10 11 12 13
# == Schema Information
#
# Table name: subscriptions
#
#  id                :integer          not null, primary key
#  user_id           :integer
#  subscribable_id   :integer
#  subscribable_type :string(255)
#  subscribed        :boolean
#  created_at        :datetime
#  updated_at        :datetime
#

14
class Subscription < ActiveRecord::Base
Valery Sizov committed
15
  belongs_to :user
16 17 18
  belongs_to :subscribable, polymorphic: true

  validates :user_id, 
Valery Sizov committed
19
            uniqueness: { scope: [:subscribable_id, :subscribable_type] },
20 21
            presence: true
end