Sha256: 706f17b7086422d7791d6ae6adeac13ba4d6a74b2f4f66fdc2c50ca30730173d

Contents?: true

Size: 467 Bytes

Versions: 2

Compression:

Stored size: 467 Bytes

Contents

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

    belongs_to :thread

    attr_accessible :subscriber, :thread

    validates_presence_of :subscriber, :thread

    validates_uniqueness_of :thread_id, :scope => [:subscriber_type, :subscriber_id]

    def mark_as_read
      self.update_attribute(:unread, 0)
    end

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
commontator-2.0.1 app/models/commontator/subscription.rb~
commontator-2.0.0 app/models/commontator/subscription.rb~