debian-mirror-gitlab/app/models/subscription.rb
2018-11-18 11:00:15 +05:30

11 lines
356 B
Ruby

# frozen_string_literal: true
class Subscription < ActiveRecord::Base
belongs_to :user
belongs_to :project
belongs_to :subscribable, polymorphic: true # rubocop:disable Cop/PolymorphicAssociations
validates :user, :subscribable, presence: true
validates :project_id, uniqueness: { scope: [:subscribable_id, :subscribable_type, :user_id] }
end