2015-03-16 11:20:17 -04:00
|
|
|
# == 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
|
|
|
|
#
|
|
|
|
|
2015-03-16 09:22:50 -04:00
|
|
|
class Subscription < ActiveRecord::Base
|
2015-03-16 09:35:48 -04:00
|
|
|
belongs_to :user
|
2015-03-16 09:22:50 -04:00
|
|
|
belongs_to :subscribable, polymorphic: true
|
|
|
|
|
2016-03-01 11:33:13 -05:00
|
|
|
validates :user_id,
|
2015-03-16 09:35:48 -04:00
|
|
|
uniqueness: { scope: [:subscribable_id, :subscribable_type] },
|
2015-03-16 09:22:50 -04:00
|
|
|
presence: true
|
|
|
|
end
|