LoadError:无法自动加载常量(Rails + Sidekiq)

在我的开发环境中,出现此错误:

WARN: LoadError: Unable to autoload constant Alerts::FailedReportWorker, expected /my-path/app/workers/alerts/failed_report_worker.rb to define it.

我的schedule.yml文件中有这些工人:

alert_sla_worker:
  cron: "*/1 * * * *"
  class: "Alerts::SlaWorker"
alert_failed_export_worker:
  cron: "*/1 * * * *"
  class: "Alerts::FailedExportWorker"
alert_failed_report_worker:
  cron: "*/1 * * * *"
  class: "Alerts::FailedReportWorker"
alert_failed_extractor_worker:
  cron: "*/1 * * * *"
  class: "Alerts::FailedExtractorWorker"

我的文件夹结构如下所示:

workers
 alerts(folder)
  failed_export_worker.rb
  failed_extractor_worker.rb
  failed_report_worker.rb
  sla_worker.rb

和failed_report_worker.rb:

# frozen_string_literal: true

module Alerts
  class FailedReportWorker
    include Sidekiq::Worker

    sidekiq_options queue: :default, retry: 0

    def perform
        ...
    end
  end
end

如何解决此问题?我不确定我缺少什么!

评论