Sidekiq 3.4.2 and Rails 4.2.0 having error with 'undefined method perform_at'

3.7k Views Asked by At

I have jobs class for ex

class TempJob < ActiveJob::Base
    queue_as :default # To Do Design Queue

    around_perform do |job, block|
        puts "Before Perform'

        block.call

        puts "After Perform"
    end

    def perform(*args)
        puts "Job Start"
    end
end

I am trying to schedule job to be execute 1hours from now

TempJob.perform_at(1.hour.from_now)

but it is giving me following error

NoMethodError: undefined method `perform_at' for TempJob:Class

Using Rails 4.2.0, Ruby 2.2.0, and Sidekiq 3.4.2.

1

There are 1 best solutions below

0
Tamer Shlash On BEST ANSWER

perform_at is the name of the method provided by Sidekiq, not ActiveJob. If you want to schedule a job to run at a relative time using ActiveJob, you should use the ActiveJob's set method like this:

TempJob.set(wait: 1.hour).perform_later

Also take a look at the ActiveJob basics guide.