gpt4 book ai didi

ruby-on-rails - 加载错误 : Unable to autoload constant (Rails + Sidekiq)

转载 作者:行者123 更新时间:2023-12-05 01:36:41 29 4
gpt4 key购买 nike

在我的开发环境中,我遇到了这个错误:

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

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

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

我该如何解决这个问题?我不确定我错过了什么!

最佳答案

这可能是自动加载的问题...我最近遇到过此类问题。尝试这样做:在 workers 目录下添加一个名为 alerts.rb 的文件,其中包含以下代码:

# frozen_string_literal: true

module Alerts; end

如果有帮助就太好了

关于ruby-on-rails - 加载错误 : Unable to autoload constant (Rails + Sidekiq),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61731725/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com