Category: Ruby on Rails
Date: 2013-07-12 16:04

Use Delayed Job with Devise mailers

In order to have Devise send its emails by background process application Delayed Job just include one line of code after your Devise declaration in your user model. Devise uses one method for all mailers. So all modules make use of it, including extensions like DeviseInvitable (check their code for this method!).

Code:  Select all
class User < ActiveRecord::Base
  devise :database_authenticatable, :recoverable, :lockable, :trackable, :timeoutable, :invitable
 
  # Use delayed job to send emails from Devise and DeviseInvitable
  handle_asynchronously :send_devise_notification, :queue => 'devise'
 
end

Tested on Rails 3.2.13 with Devise 2.2.4 and Delayed Job 3.0.5

  •  
  • 0 Comment(s)
  •  

Your comment

Notify me when someone adds another comment to this post

back