Skip to content

Commit

Permalink
use pony instead of action-mailer if loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
mkristian committed Dec 18, 2012
1 parent 83d727f commit 8041e0c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 12 deletions.
29 changes: 21 additions & 8 deletions lib/ixtlan/errors/mailer.rb
@@ -1,14 +1,27 @@
module Ixtlan
module Errors
class Mailer < ActionMailer::Base
if defined? Pony

class Mailer
def error_notification(email_from, emails_to, exception, error_url)
Pony.mail( :from => email_from,
:to => emails_to,
:subject => exception.message,
:body => "#{error_url}" )
end
end

else
class Mailer < ActionMailer::Base

def error_notification(email_from, emails_to, exception, error_url)
@subject = exception.message
@text = "#{error_url}"
@recipients = emails_to
@from = email_from
@sent_on = Time.now
@headers = {}
def error_notification(email_from, emails_to, exception, error_url)
@subject = exception.message
@text = "#{error_url}"
@recipients = emails_to
@from = email_from
@sent_on = Time.now
@headers = {}
end
end
end
end
Expand Down
10 changes: 6 additions & 4 deletions lib/ixtlan/errors/railtie.rb
Expand Up @@ -8,10 +8,12 @@ module Errors
class Railtie < Rails::Railtie

config.before_configuration do |app|

path = File.join(File.dirname(__FILE__), "..", "..")
unless ActionMailer::Base.view_paths.member? path
ActionMailer::Base.view_paths= [ActionMailer::Base.view_paths, path].flatten

unless defined? Pony
path = File.join(File.dirname(__FILE__), "..", "..")
unless ActionMailer::Base.view_paths.member? path
ActionMailer::Base.view_paths= [ActionMailer::Base.view_paths, path].flatten
end
end

app.config.error_dumper = ErrorDumper.new
Expand Down

0 comments on commit 8041e0c

Please sign in to comment.