Creating an background job with the resque_scheduler gem on Redis server.
class Estamps::OrderAssignment < ActiveRecord::Base after_save :enqueue_check_status def enqueue_check_status AutoRejectionJob.set(wait: 2.minutes).perform_later(self.id) end end class AutoRejectionJob < ActiveJob::Base queue_as :default def perform(*args) order_assignment_id = args[0] order_assignment = Estamps::OrderAssignment.find(order_assignment_id) if order_assignment.status_id == 1 || order_assignment.status_id == nil order_assignment.status_id = 3 order_assignment.save! end end end
On creation of OrderAssignment record or when updated after 2 minutes it should run AutoRejection Job. Here the prob is the set(wait: 2.minutes) does not seem to run, i.e.
AutoRejectionJob.perform_later(self.id)
works perfectly fine, but
AutoRejectionJob.set(wait: 2.minutes).perform_later(self.id)
does nothing. Haven't been able to rectify the issue. Newbie to Rails so please help.