matiss
matiss

Reputation: 747

Rails 5.2.3: Sidekiq Scheduler gives NameError: uninitialized constant in Production

In my Rails 5.2.3 app I have config/sidekiq.yml which looks like this:

:verbose: true
:concurrency: 30
:queues:
  - [mailers, 7]
  - [critical, 6]
  - [default, 5]
  - [low, 4]

:logfile: ./log/sidekiq.log

:schedule:
  ScheduledNotices:
    queue: low
    cron: '0 0 * * * *' # every hour

My ScheduledNotices is placed in lib\scheduled_notices.rb

At the moment in development environment Scheduler works as expected, however in production I get this error: NameError: uninitialized constant ScheduledNotices

In my application.rb I have:

config.autoload_paths += %W(#{config.root}/lib)

What am I doing wrong, please?

Upvotes: 0

Views: 1366

Answers (1)

nuaky
nuaky

Reputation: 2086

It can be realated to path autoload issue, check this for more details: https://github.com/rails/rails/issues/13142#issuecomment-275492070

What you should do is to change:

config.autoload_paths += %W(#{config.root}/lib)

to

config.eager_load_paths << Rails.root.join('lib')

Upvotes: 1

Related Questions