Created
February 25, 2011 17:17
-
-
Save trevorturk/844117 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
# config/initializers/email_logger.rb | |
class EmailLogger | |
def self.delivered_email(email) | |
EmailLog.create!( | |
:from => email.from, | |
:to => email.to, | |
:subject => email.subject, | |
:body => email.body.inspect, | |
:date => email.date | |
) | |
end | |
Mail.register_observer(EmailLogger) | |
# app/models/email_log.rb | |
class EmailLog | |
include Mongoid::Document | |
field :from, :type => Array | |
field :to, :type => Array | |
field :subject | |
field :body | |
field :date, :type => DateTime | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
you are missing a closing end to the delivered_email method ;)