2015-03-16 09:22:50 -04:00
|
|
|
class Subscription < ActiveRecord::Base
|
2015-03-16 09:35:48 -04:00
|
|
|
belongs_to :user
|
2016-10-31 13:40:27 -04:00
|
|
|
belongs_to :project
|
2015-03-16 09:22:50 -04:00
|
|
|
belongs_to :subscribable, polymorphic: true
|
|
|
|
|
2016-11-14 17:42:22 -05:00
|
|
|
validates :user, :subscribable, presence: true
|
2016-10-31 13:40:27 -04:00
|
|
|
|
2016-11-14 17:42:22 -05:00
|
|
|
validates :project_id, uniqueness: { scope: [:subscribable_id, :subscribable_type, :user_id] }
|
2015-03-16 09:22:50 -04:00
|
|
|
end
|