Sidekiq找不到Rails Active Job的记录 [英] Sidekiq not finding records for Rails Active Job
本文介绍了Sidekiq找不到Rails Active Job的记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在模型中创建用户后,作业就排队
Jobs are queued on after a user is created like so in the model
user.rb
after_create_commit :profile_photo_job
def profile_photo_job
message = "Add a profile photo"
ReminderJob.set(wait: 1800).perform_later(self.id.to_s, message)
end
reminder_job.rb
class ReminderJob < ApplicationJob
queue_as :default
def perform(user_id, message)
if user_id
user = User.find(user_id)
end
##sending message notification here
end
end
但是,它通常会在我的sidekiq控制台内引发以下错误
However, it often throws the following error inside my sidekiq console
ActiveRecord :: RecordNotFound:找不到'id'= 7749 $的用户b $ b处理器:User-MacBook-Pro.local:*****
ActiveRecord::RecordNotFound: Couldn't find User with 'id'=7749 Processor: User-MacBook-Pro.local:*****
此错误在生产中发生。
推荐答案
在User.rb
after_commit :profile_photo_job, on: :create
def profile_photo_job
message = "Add a profile photo"
ReminderJob.set(wait: 1800).perform_later(self.id.to_s, message)
end
这篇关于Sidekiq找不到Rails Active Job的记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文