gitlab-org--gitlab-foss/app/models/subscription.rb
Yorick Peterse 5819ca1a24
Added Cop to blacklist polymorphic associations
One should really use a separate table instead of using polymorphic
associations.

See https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/11168 for
more information.
2017-06-07 17:36:55 +02:00

9 lines
325 B
Ruby

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