Sha256: d5d93ed08c000fc19e1ad4889135afcf734fc74deaf4f7cb8fb747414e6bb189
Contents?: true
Size: 526 Bytes
Versions: 1
Compression:
Stored size: 526 Bytes
Contents
class ForumSubscription < ApplicationRecord belongs_to :forum_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: :forum_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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
simple_discussion-1.3.0 | app/models/forum_subscription.rb |