Sha256: 89bad7946bfa20a19adcbff869681d87a380188484f8b25ac09d95d4ac037ee4
Contents?: true
Size: 536 Bytes
Versions: 9
Compression:
Stored size: 536 Bytes
Contents
class SupportSubscription < ApplicationRecord belongs_to :support_thread belongs_to :user scope :optin, ->{ where(subscription_type: :optin) } scope :optout, ->{ where(subscription_type: :optout) } validates :subscription_type, presence: true, inclusion: { in: %w{ optin optout } } validates :user_id, uniqueness: { scope: :support_thread_id } def toggle! case subscription_type when "optin" update(subscription_type: "optout") when "optout" update(subscription_type: "optin") end end end
Version data entries
9 entries across 9 versions & 1 rubygems