Ruby on Rails,delayed_job
我正在使用这个gem作为我的应用程序。 我找不到我需要的参数。我的控制器中有两个function:创建和分析。 我想在调用create analyse-method
后5分钟后运行一个analyse-method
,或者我在模型中还有一个函数:进程我希望在5分钟后运行一个anylse-method
(来自控制器),当一个进程方法是调用。
我找到了这样的smt:
handle_asynchronously :in_the_future, :run_at => Proc.new { 5.minutes.from_now }
但它没有说它应该被称为function之后。
编辑:我试图延迟我的工作,它似乎保存了一切,问题是1分钟后它没有运行perform_analysis
方法。 可能是什么问题?
模型:
after_create :process_name, :perform_analysis def perform_analysis list=Analysis.do_picture_analyse update_image_url(list) end handle_asynchronously :perform_analysis, :run_at => Proc.new { 1.minutes.from_now }
SQL(8.3ms)INSERT INTO“delayed_jobs”(“尝试”,“created_at”,“failed_at”,“handler”,“last_error”,“locked_at”,“locked_by”,“priority”,“queue”,“run_at” ,“updated_at”)VALUES(?,?,?,?,?,?,?,?,?,?,?)[[“尝试”,0],[“created_at”,星期六,2013年3月16日14: 30:19 UTC +00:00],[“failed_at”,nil],[“handler”,“—!ruby / object:Delayed :: PerformableMethod \ nobject:!ruby / ActiveRecord:Arraydb \ n属性:\ n id:45 \ n arraydb_file_name:ND2_CD8_133A.CEL \ n arraydb_content_type:!binary | – \ n YXBwbGljYXRpb24vb2N0ZXQtc3RyZWFt \ n arraydb_file_size:12110237 \ n已定义:’是’\ n患者:ND \ n组织:CD8 \ n刺激:\ n chip_image:\ n chip_info:\ n user_id:\ n hist:\ n hist_RMA:\ n created_at:2013-03-16 14:30:17.698742003 Z \ n updated_at:2013-03-16 14:30:19.297934640 Z \ nmethod_name :: perform_analysis_without_delay \ nargs:[] \ n“],[”last_error“,nil],[”locked_at“,nil],[”locked_by“,nil],[”priority“,0],[”queue“, nil],[“run_at”,星期六,2013年3月16日14:31:19 UTC +00:00],[“updated_at”,星期六, 2013年3月16日14:30:19 UTC +00:00]]
提前致谢
您可以使用回调来触发该方法。 这将触发方法:in_the_future
在作为延迟作业排队,在创建操作完成后运行5分钟。
after_create :in_the_future