Skip to content

Instantly share code, notes, and snippets.

@mguterl
Created December 2, 2011 15:39
Show Gist options
  • Select an option

  • Save mguterl/1423669 to your computer and use it in GitHub Desktop.

Select an option

Save mguterl/1423669 to your computer and use it in GitHub Desktop.
Silence ActionMailer warnings when using deliver_* class methods
# The ActionMailer interface in Rails >= 3 sucks. Besides when
# testing the mailer, I see no reason to instantiate an object and
# then deliver it. Extend your mailer with this module to silence the
# warnings and enjoy life once again.
module SilenceDeliverWarnings
def method_missing(method, *args)
if method.to_s =~ /^deliver_(.*)/
send($1, *args).deliver
else
super
end
end
end
class Mailer < ActionMailer::Base
extend SilenceDeliverWarnings
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment