问题
In my development environement I am getting this error :
WARN: LoadError: Unable to autoload constant Alerts::FailedReportWorker, expected /my-path/app/workers/alerts/failed_report_worker.rb to define it.
I have these workers in my schedule.yml file :
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"
My folder structure looks like this :
workers
alerts(folder)
failed_export_worker.rb
failed_extractor_worker.rb
failed_report_worker.rb
sla_worker.rb
And 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
How can I fix this issue ? I'm not sure what I'm missing!
回答1:
It may be issue with autoloading... I've faced this type of issue recently.
Try to do this:
add under workers
directory a file named alerts.rb
with following code inside:
# frozen_string_literal: true
module Alerts; end
It would be great if it helps
来源:https://stackoverflow.com/questions/61731725/loaderror-unable-to-autoload-constant-rails-sidekiq