Skip to content

Instantly share code, notes, and snippets.

@adamgamble
Created August 9, 2013 02:56
Show Gist options
  • Save adamgamble/6190838 to your computer and use it in GitHub Desktop.
Save adamgamble/6190838 to your computer and use it in GitHub Desktop.
class Comment < ActiveRecord::Base
belongs_to :article
validates_presence_of :name, :email, :body
validate :article_should_be_published
after_create :email_article_author
after_create :send_comment_email
def article_should_be_published
errors.add(:article_id, "is not published yet") if article && !article.published?
end
def email_article_author
puts "We will notify #{article.user.email} the author in Chapter 9"
end
def send_comment_email
Notifier.comment_added(comment).deliver
end
end
@lmuhammad1
Copy link

line 20 should read:
Notifier.comment_added(self).deliver

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment