gpt4 book ai didi

ruby-on-rails-3 - delayed_job :run_at is not working. 所有作业设置为在当前时间运行

转载 作者:行者123 更新时间:2023-12-03 22:45:09 26 4
gpt4 key购买 nike

我已经为 delayed_job 安装了 collectiveidea fork

git://github.com/collectiveidea/delayed_job.git

但无法让它接受 :run_at

来 self 的 gemfile

gem 'rails', '3.2.2'
gem 'delayed_job_active_record'

当我在控制台中尝试时

1.9.2-p318 :005 > Time.now
=> 2012-03-24 10:20:34 -0700
1.9.2-p318 :006 > User.delay.new :run_at => 5.days.from_now
SQL (0.1ms) BEGIN
SQL (1.6ms) INSERT INTO `delayed_jobs` (`attempts`, `created_at`, `failed_at`, `handler`, `last_error`, `locked_at`, `locked_by`, `priority`, `run_at`, `updated_at`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) [["attempts", 0], ["created_at", Sat, 24 Mar 2012 17:20:36 UTC +00:00], ["failed_at", nil], ["handler", "--- !ruby/object:Delayed::PerformableMethod\nobject: !ruby/class 'User'\nmethod_name: :new\nargs:\n- :run_at: 2012-03-29 17:20:36.876374000Z\n"], ["last_error", nil], ["locked_at", nil], ["locked_by", nil], ["priority", 0], ["run_at", Sat, 24 Mar 2012 17:20:36 UTC +00:00], ["updated_at", Sat, 24 Mar 2012 17:20:36 UTC +00:00]]
(2.7ms) COMMIT
=> #<Delayed::Backend::ActiveRecord::Job id: 17, priority: 0, attempts: 0, handler: "--- !ruby/object:Delayed::PerformableMethod\nobject:...", last_error: nil, run_at: "2012-03-24 17:20:36", locked_at: nil, failed_at: nil, locked_by: nil, created_at: "2012-03-24 17:20:36", updated_at: "2012-03-24 17:20:36">

我看到运行时有一些 UTC 偏移量,但基于 Time.now,我可以看出 run_at 不会提前 5 天。

“run_at”,2012 年 3 月 24 日星期六 17:20:36 UTC +00:00

有什么想法吗?

最佳答案

你在传递 :run_at 作为参数来初始化 User 模型的方法时犯了一个错误。

尝试:

User.delay(:run_at => 5.days.from_now).new

关于ruby-on-rails-3 - delayed_job :run_at is not working. 所有作业设置为在当前时间运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9853842/

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