Skip to content

Instantly share code, notes, and snippets.

@invisiblefunnel
Created December 9, 2013 02:18
Show Gist options
  • Select an option

  • Save invisiblefunnel/7866510 to your computer and use it in GitHub Desktop.

Select an option

Save invisiblefunnel/7866510 to your computer and use it in GitHub Desktop.
Mailers with Sidekiq
require 'devise/mailer'
#
# General mailer proxy class to send emails in the background w/ Sidekiq
#
class BackgroundMailer
def self.reset_password_instructions(record, token, opts={})
new(Devise::Mailer, :reset_password_instructions, record, token, opts)
end
def initialize(mailer_klass, method, *args)
@mailer_klass = mailer_klass
@method = method
@args = args
end
def deliver
@mailer_klass.delay.send(@method, *@args)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment