From 334f84179fb54a375df4b21a925ecefc0e10b795 Mon Sep 17 00:00:00 2001 From: Henne Vogelsang Date: Tue, 29 Jan 2019 23:20:22 +0100 Subject: [PATCH] Use deliver_later in devise Do not send devise mails directly in the request but through the delayed jobs. --- app/controllers/admin/booths_controller.rb | 4 ++-- app/models/user.rb | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/controllers/admin/booths_controller.rb b/app/controllers/admin/booths_controller.rb index 7f46c2bd..b39a2df4 100644 --- a/app/controllers/admin/booths_controller.rb +++ b/app/controllers/admin/booths_controller.rb @@ -70,7 +70,7 @@ module Admin if @booth.save if @conference.email_settings.send_on_booths_acceptance - Mailbot.conference_booths_acceptance_mail(@booth).deliver + Mailbot.conference_booths_acceptance_mail(@booth).deliver_later end redirect_to admin_conference_booths_path(conference_id: @conference.short_title), notice: 'Booth successfully accepted!' @@ -92,7 +92,7 @@ module Admin @booth.reject! if @booth.save - Mailbot.conference_booths_rejection_mail(@booth).deliver + Mailbot.conference_booths_rejection_mail(@booth).deliver_later redirect_to admin_conference_booths_path(conference_id: @conference.short_title), notice: 'Booth successfully rejected.' else diff --git a/app/models/user.rb b/app/models/user.rb index 12d58c54..bc71f61f 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -287,4 +287,8 @@ class User < ApplicationRecord errors.add(:biography, 'is limited to 150 words.') if biography.split.length > 150 end end + + def send_devise_notification(notification, *args) + devise_mailer.send(notification, self, *args).deliver_later + end end