2018-07-25 05:30:33 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-03-28 09:17:42 -04:00
|
|
|
class UserCallout < ApplicationRecord
|
2018-01-26 11:06:52 -05:00
|
|
|
belongs_to :user
|
2018-02-01 21:07:33 -05:00
|
|
|
|
2020-07-31 20:09:45 -04:00
|
|
|
# We use `UserCalloutEnums.feature_names` here so that EE can more easily
|
2018-11-13 11:29:14 -05:00
|
|
|
# extend this `Hash` with new values.
|
2020-07-31 20:09:45 -04:00
|
|
|
enum feature_name: ::UserCalloutEnums.feature_names
|
2018-02-02 18:16:24 -05:00
|
|
|
|
2018-02-01 21:07:33 -05:00
|
|
|
validates :user, presence: true
|
2018-02-02 18:16:24 -05:00
|
|
|
validates :feature_name,
|
|
|
|
presence: true,
|
|
|
|
uniqueness: { scope: :user_id },
|
|
|
|
inclusion: { in: UserCallout.feature_names.keys }
|
2020-02-06 13:08:54 -05:00
|
|
|
|
|
|
|
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-01-26 11:06:52 -05:00
|
|
|
end
|