Class: CommentObserver

Inherits:
ActiveRecord::Observer
  • Object
show all
Defined in:
lib/forge/app/models/comment_observer.rb

Instance Method Summary collapse

Instance Method Details

#after_save(comment) ⇒ Object



2
3
4
5
6
7
8
# File 'lib/forge/app/models/comment_observer.rb', line 2

def after_save(comment)
  # create subscriber
  CommentSubscriber.create(:commentable => comment.commentable, :email => comment.author_email) if comment.subscribe.to_i == 1

  # notify subscribers
  comment.commentable.subscribers.each {|subscriber| CommentMailer.comment_notification(subscriber.email, comment).deliver} if comment.approved?
end