From 5a37fa3760e022fbbaa0f259f6c3aff5c94606f4 Mon Sep 17 00:00:00 2001 From: Alan Guo Xiang Tan Date: Thu, 25 Jul 2024 15:52:42 +0800 Subject: [PATCH] FIX: Fix `Jobs::Onceoff.enqueue_all` undefined method for nilClass error (#28073) In development, classes are lazy loaded so `Jobs::Onceoff.onceoff_job_klasses` may not have been set. This is not a problem in production cause stuff is eager loaded. Follow-up to f4d06f195d583794313943e73b1b31d28151b85c --- app/jobs/onceoff/onceoff.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/jobs/onceoff/onceoff.rb b/app/jobs/onceoff/onceoff.rb index 40ff504714e..c795c0b916b 100644 --- a/app/jobs/onceoff/onceoff.rb +++ b/app/jobs/onceoff/onceoff.rb @@ -4,11 +4,14 @@ class Jobs::Onceoff < ::Jobs::Base sidekiq_options retry: false class << self - attr_reader :onceoff_job_klasses + @@onceoff_job_klasses = Set.new def inherited(klass) - @onceoff_job_klasses ||= Set.new - @onceoff_job_klasses << klass + @@onceoff_job_klasses << klass + end + + def onceoff_job_klasses + @@onceoff_job_klasses end end