Sha256: 9ebc1bbce4cd08b6857ae2bb47475b04514d62ec34ab5aeb43155d43eedb561d

Contents?: true

Size: 413 Bytes

Versions: 15

Compression:

Stored size: 413 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

15 entries across 15 versions & 1 rubygems

Version Path
commontator-4.5.4 app/models/commontator/subscription.rb
commontator-4.5.3 app/models/commontator/subscription.rb
commontator-4.5.2 app/models/commontator/subscription.rb
commontator-4.5.1 app/models/commontator/subscription.rb
commontator-4.5.0 app/models/commontator/subscription.rb
commontator-4.4.1 app/models/commontator/subscription.rb
commontator-4.3.0 app/models/commontator/subscription.rb
commontator-4.2.2 app/models/commontator/subscription.rb
commontator-4.2.1 app/models/commontator/subscription.rb
commontator-4.2.0 app/models/commontator/subscription.rb
commontator-4.1.2 app/models/commontator/subscription.rb
commontator-4.1.1 app/models/commontator/subscription.rb
commontator-4.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