Skip to content

Instantly share code, notes, and snippets.

@ccjr
Created April 6, 2010 19:51
Show Gist options
  • Save ccjr/358011 to your computer and use it in GitHub Desktop.
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
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