How do I schedule recurring jobs in Active Job (Rails 4.2)?

Similar to rab3’s answer, since ActiveJob has support for callbacks, I was thinking of doing something like

class MyJob < ActiveJob::Base
  after_perform do |job|
    # invoke another job at your time of choice 
    self.class.set(:wait => 10.minutes).perform_later(job.arguments.first)
  end

  def perform(the_argument)
    # do your thing
  end
end

activejob callbacks

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)