首页 > 解决方案 > Rails 5 gem'delayed_job_active_record'未初始化的常量作业

问题描述

我有两个工作要在生产中运行,一个总是工作正常,但另一个有时会因错误而卡住

 uninitialized constant AppointmentReminderJob\nDid you mean? 
 AppointmentLog\n/Path/shared/bundle/ruby/2.5.0/gems/activesupport- 
 5.2.4.1/lib/active_support/inflector/methods.rb:283:in

通过生产开始延迟工作RAILS_ENV=production bin/delayed_job restart

application.rb 集合 config.active_job.queue_adapter = :delayed_job

文件名appointment_reminder_job.rb

class AppointmentReminderJob < ApplicationJob
  queue_as :default

  def perform(appointment, clinic)
     # My code here
  end
end

设置作业

AppointmentReminderJob.set(wait_until: Appointment::TIME_LIMIT).perform_later(@appointment, @clinic)

注意:我并不总是但有时会收到此错误。

标签: ruby-on-railsruby-on-rails-5delayed-jobrails-activejob

解决方案


推荐阅读