Sha256: 0e9876f8cd9f322a4ff912116d489ede68b407a425c9a4766134202f1e365058

Contents?: true

Size: 414 Bytes

Versions: 3

Compression:

Stored size: 414 Bytes

Contents

module Commontator
  class Subscription < ActiveRecord::Base
    belongs_to :subscriber, :polymorphic => true

    belongs_to :thread

    validates_presence_of :subscriber, :thread
    validates_uniqueness_of :thread_id, :scope => [:subscriber_type, :subscriber_id]

    def mark_as_read
      update_attribute(:unread, 0)
    end

    def add_unread
      update_attribute(:unread, unread + 1)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
commontator-2.0.2 app/models/commontator/subscription.rb~
commontator-4.0.1 app/models/commontator/subscription.rb~
commontator-4.0.0 app/models/commontator/subscription.rb~