You can configure resque to work with ActionMailer. Add gem 'resque' to your gemfile. Make change to adapter in application.rb - config.active_job.queue_adapter = :resque Use the following to generate a job - rails g job WelcomeEmail class WelcomeEmail < ActiveJob :: Base queue_as : default def perform ( fg_id , mailing_id ) fg = Fg . where ( 'id = ?' , fg_id ). first mailing = Mailing . where ( 'id = ?' , mailing_id ). first SendWelcomeMail. contact ( fg , mailing ). deliver_now end end In your controller, you can do WelcomeEmail . set ( wait : 10.seconds ). perform_later ( @fg . id , @mailing . id ) Source: stackoverflow
ruby on rails cheat sheet, ruby libraries, ruby on rails concepts, rails tutorials for beginner, ruby on rails