Skip to content

Instantly share code, notes, and snippets.

@enriclluelles
Created June 19, 2012 12:21
Show Gist options
  • Select an option

  • Save enriclluelles/2953840 to your computer and use it in GitHub Desktop.

Select an option

Save enriclluelles/2953840 to your computer and use it in GitHub Desktop.
mailing with resque
#encoding: UTF-8
require 'resque_mail'
class PostOffice < ActionMailer::Base
extend ResqueMail
@queue = :mail
end
require 'resque'
module ResqueMail
#Resque executes it's jobs using this method
def perform(template, *args)
self.send(template, *args).deliver
end
def send_mail(*args)
if Rails.env.production?
Resque.enqueue(self, *args)
else
self.perform(*args)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment