Sha256: 88cd16dff6c5f6b7bf2febb07353e314c70d6854431ac0bd7529129f39440a28

Contents?: true

Size: 657 Bytes

Versions: 6

Compression:

Stored size: 657 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 self.comment_created(comment)
      recipients = comment.thread.subscribers.reject{|s| s == comment.creator}
      SubscriptionsMailer.comment_created(comment, recipients).deliver \
        unless recipients.empty?
    end

    def unread_comments
      created_at = Comment.arel_table[:created_at]
      thread.filtered_comments.where(created_at.gt(updated_at))
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
commontator-4.8.0 app/models/commontator/subscription.rb
commontator-4.7.2 app/models/commontator/subscription.rb
commontator-4.7.1 app/models/commontator/subscription.rb
commontator-4.7.0 app/models/commontator/subscription.rb
commontator-4.6.1 app/models/commontator/subscription.rb
commontator-4.6.0 app/models/commontator/subscription.rb