From f8fef934f3c2bd3b0b278905f7ed70980f682735 Mon Sep 17 00:00:00 2001 From: Baron Bloomer Date: Thu, 1 Jul 2021 17:06:35 +0100 Subject: [PATCH] Check Rails is defined before referring to Rails Fixes issue https://github.com/collectiveidea/delayed_job/issues/1145 --- lib/delayed/worker.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/delayed/worker.rb b/lib/delayed/worker.rb index 1a352f775..b4497649b 100644 --- a/lib/delayed/worker.rb +++ b/lib/delayed/worker.rb @@ -116,7 +116,7 @@ def self.setup_lifecycle end def self.reload_app? - defined?(ActionDispatch::Reloader) && Rails.application.config.cache_classes == false + defined?(ActionDispatch::Reloader) && defined?(Rails) && Rails.application.config.cache_classes == false end def self.delay_job?(job) @@ -326,7 +326,7 @@ def reserve_job def reload! return unless self.class.reload_app? - if defined?(ActiveSupport::Reloader) + if defined?(ActiveSupport::Reloader) && defined?(Rails) Rails.application.reloader.reload! else ActionDispatch::Reloader.cleanup!