Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Callback after delayed_job process job

I need to update a model after delayed_job processes a task on it, e.g:

foo.delay.something

After something is done, I need to update the foo object, what is the best way to achieve this? I was thinking in coding a callback on the Delayed::Backend::ActiveRecord::Job class, but there's should be something cleaner and better to do this.

like image 710
jpemberthy Avatar asked Oct 14 '22 03:10

jpemberthy


1 Answers

I would just updated it at the end of the #foo method:

def foo
  # do work here
  update_attribute :processed, true
end
like image 132
bkeepers Avatar answered Oct 30 '22 02:10

bkeepers