我在
安装了delayed_job的collectiveidea分叉git://github.com/collectiveidea/delayed_job.git
但无法接受:run_at
来自我的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
有什么想法吗?
答案 0 :(得分:13)
你传递错误:run_at作为初始化用户模型方法的参数。
尝试:
User.delay(:run_at => 5.days.from_now).new