简体   繁体   English

delay_jobs没有在delay_jobs表中创建行

[英]delayed_jobs not creating rows in delayed_jobs table

In may rails application i wanted to use delayed job. 在May Rails应用程序中,我想使用延迟的工作。 SO i installed delayed jobs as follows. 所以我安装了延迟的工作如下。

in gemfile 在gemfile中

 gem 'delayed_job_active_record', '0.4.3'

then in console 然后在控制台

 rails generate delayed_job:active_record

 rake db:create

It had created delayed_jobs table in database. 它已在数据库中创建了delay_jobs表。

And i started 然后我开始

 rake jobs:work

Then i added the following code in controller: 然后我在控制器中添加了以下代码:

 Task.handle_asynchronously :in_the_future, :run_at => Proc.new { 5.minutes.from_now }

here Task is the model name. Task是模型名称。

And in the model task.rb i wrote 在模型task.rb中,我写了

 def in_the_future
   self.update_attiributes(:status=> "updated")
 end

After running controller method it's not creating any record in the delayed_jobs table. 运行控制器方法后,不会在delay_jobs表中创建任何记录。 Please correct me if i am doing anything wrong. 如果我做错了什么,请纠正我。

您可以将控制器代码更改为

Task.delay(:run_at => Proc.new { 5.minutes.from_now }).in_the_future

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM