Created
April 6, 2010 19:51
-
-
Save ccjr/358011 to your computer and use it in GitHub Desktop.
[Beginning Rails 3] Listing 9-11. Adding the comment_added method to app/models/notifier.rb
This file contains 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 Notifier < ActionMailer::Base | |
default :from => "from@example.com" | |
def email_friend(article, sender_name, receiver_email) | |
@article = article | |
@sender_name = sender_name | |
attachments["rails.png"] = File.read(Rails.root.join("public/images/rails.png")) | |
mail :to => receiver_email, :subject => "Interesting Article" | |
end | |
def comment_added(comment) | |
@article = comment.article | |
mail :to => @article.user.email, :subject => "New comment for '#{@article.title}'" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment