Devise Async provides an easy way to configure Devise to send its emails asynchronously using your preferred queuing backend.
Add this line to your application's Gemfile:
And then execute:
Or install it yourself as:
$ gem install devise-async
Devise::Async::Model to your Devise model
class User < ActiveRecord::Base devise :database_authenticatable, :confirmable # etc ... include Devise::Async::Model # should be below call to `devise` end
Devise::Async::Proxy as Devise's mailer in
# Configure the class responsible to send e-mails. config.mailer = "Devise::Async::Proxy"
Set your queuing backend by creating
# Supported options: :resque, :sidekiq, :delayed_job Devise::Async.backend = :resque
Tip: it defaults to Resque. You don't need to create the initializer if using it.
If you inherit
Devise::Mailer to a class of your own for customization purposes,
you'll need to tell
Devise::Async to proxy to that class.
# config/initializers/devise_async.rb Devise::Async.mailer = "MyCustomMailer"
Let you specify a custom queue where to enqueue your background Devise jobs. Works only for Resque and Sidekiq. Defaults to :mailer.
# config/initializers/devise_async.rb Devise::Async.queue = :my_custom_queue
To avoid repeating
Devise::Async in the initializer file you can use the block syntax
similar do what
# config/initializers/devise_async.rb Devise::Async.setup do |config| config.backend = :resque config.mailer = "MyCustomMailer" config.queue = :my_custom_queue end
- Fork it
- Create your feature branch (
git checkout -b my-new-feature)
- Commit your changes (
git commit -am 'Added some feature')
- Push to the branch (
git push origin my-new-feature)
- Create new Pull Request
Released under the MIT License. See the LICENSE file for further details.