2018-11-18 11:00:15 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-07-07 11:18:12 +05:30
|
|
|
class UserCallout < ApplicationRecord
|
2018-03-17 18:26:18 +05:30
|
|
|
belongs_to :user
|
|
|
|
|
2019-02-15 15:39:39 +05:30
|
|
|
# We use `UserCalloutEnums.feature_names` here so that EE can more easily
|
|
|
|
# extend this `Hash` with new values.
|
|
|
|
enum feature_name: ::UserCalloutEnums.feature_names
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
validates :user, presence: true
|
|
|
|
validates :feature_name,
|
|
|
|
presence: true,
|
|
|
|
uniqueness: { scope: :user_id },
|
|
|
|
inclusion: { in: UserCallout.feature_names.keys }
|
2020-03-09 13:42:32 +05:30
|
|
|
|
|
|
|
scope :with_feature_name, -> (feature_name) { where(feature_name: UserCallout.feature_names[feature_name]) }
|
|
|
|
scope :with_dismissed_after, -> (dismissed_after) { where('dismissed_at > ?', dismissed_after) }
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|