Created
June 19, 2012 12:21
-
-
Save enriclluelles/2953840 to your computer and use it in GitHub Desktop.
mailing with resque
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
| #encoding: UTF-8 | |
| require 'resque_mail' | |
| class PostOffice < ActionMailer::Base | |
| extend ResqueMail | |
| @queue = :mail | |
| end |
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
| 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