像模型中那样创建用户后,工作就排队
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控制台内引发以下错误
ActiveRecord :: RecordNotFound:找不到'id'= 7749的用户 处理器:User-MacBook-Pro.local:*****
此错误在生产中发生。
答案 0 :(得分:0)
在User.rb
var refreshIntervalId;
window.addEventListener("onkeydown", keyDown, true);
window.addEventListener("keydown", keyDown);
function keyDown() {
var e = window.event;
switch (e.keyCode) {
case 188:
start();
break;
case 190:
stopA();
break;
}
}
function start() {
stop();
refreshIntervalId = setInterval(function() {
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
async function demo() {
document.getElementsByClassName("list_element")[2].click();
await sleep(1000);
document.getElementsByClassName("aclist")[1].click();
await sleep(1000);
document.getElementById("pro").click();
await sleep(1000);
document.getElementsByClassName("close")[0].click();
}
demo();
}, 5000);
}
function stop() {
if (refreshIntervalId != null) {
clearInterval(refreshIntervalId);
refreshIntervalId = null;
}
}