Class: Gluttonberg::CommentSubscription

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/gluttonberg/comment_subscription.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.notify_subscribers_of(article, comment) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'app/models/gluttonberg/comment_subscription.rb', line 8

def self.notify_subscribers_of(article , comment)
  subscribers = self.find(:all , :conditions => {:article_id => article.id})
  subscribers.each do |subscriber|
    unless subscriber.author_email == comment.writer_email
      Notifier.delay.comment_notification(subscriber , article , comment ) #.deliver # its using delayed job but i am setting sent time immediately
      comment.notification_sent_at = Time.now
      comment.save
    end
  end
end

Instance Method Details

#generate_reference_hashObject



19
20
21
22
23
# File 'app/models/gluttonberg/comment_subscription.rb', line 19

def generate_reference_hash
  unless self.reference_hash
    self.reference_hash = Digest::SHA1.hexdigest(Time.now.to_s + self.author_email + self.article_id.to_s)
  end
end