From 3fdcb96d785b8ec4f6e15a033860461850739b1b Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Fri, 12 May 2017 15:34:34 +0900 Subject: [PATCH] Lazy-load ActionMailer::Base to defer :action_mailer on_load hook --- lib/letter_opener_web/engine.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/letter_opener_web/engine.rb b/lib/letter_opener_web/engine.rb index 70c767f..d73f138 100644 --- a/lib/letter_opener_web/engine.rb +++ b/lib/letter_opener_web/engine.rb @@ -7,11 +7,13 @@ class Engine < ::Rails::Engine isolate_namespace LetterOpenerWeb initializer 'letter_opener_web.add_delivery_method' do - ActionMailer::Base.add_delivery_method( - :letter_opener_web, - LetterOpenerWeb::DeliveryMethod, - location: LetterOpenerWeb.config.letters_location - ) + ActiveSupport.on_load :action_mailer do + ActionMailer::Base.add_delivery_method( + :letter_opener_web, + LetterOpenerWeb::DeliveryMethod, + location: LetterOpenerWeb.config.letters_location + ) + end end initializer 'assets' do |_app|