Search code examples
ruby-on-railsrubyqueueresque

Resque: Jobs must be placed onto a queue. No queue could be inferred for class Worker


I'm working on a rails app which involves using Resque. I have my queue defined in the worker class.

def self.queue
  @queue = :my_worker_queue
end

However I'm still getting

Jobs must be placed onto a queue. No queue could be inferred for class Worker

Any ideas about how a queue should be defined? Thanks!


Solution

  • Resque requires you to set the class-level instance variable with the queue name. That's what your self.queue method does, but it'll only do it if you actually call it.

    The easier option is to remove the self.queue method and put @queue = :my_worker_queue at the top of the class itself.

    So it would be something like

    class Worker
      @queue = :my_worker_queue
    
      def self.perform
        # do your stuff
      end
    end
    

    More information: http://tutorials.jumpstartlab.com/topics/performance/background_jobs.html