Created
August 9, 2013 02:56
-
-
Save adamgamble/6190838 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
line 20 should read:
Notifier.comment_added(self).deliver