Skip to content

Instantly share code, notes, and snippets.

@foxnewsnetwork
Created December 2, 2014 06:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save foxnewsnetwork/0eee1fc5602a162b81c4 to your computer and use it in GitHub Desktop.
Save foxnewsnetwork/0eee1fc5602a162b81c4 to your computer and use it in GitHub Desktop.
basic resque 2.0.0.pre.1 usage

Resque is great, but the README.md on github (as of 12/1/2014) continues to cause butthurt to folks who are trying to setup resque.

The current README (wrongly) states:

To define some work, make a job. Jobs need a work method:

class ImageConversionJob
  def work
    # convert some kind of image here
  end
end

Next, we need to procrastinate! Let's put your job on the queue:

resque = Resque.new
resque << ImageConversionJob.new

Here is the "correct" example usage:

Be sure that your job has a queue method so that Resque knows where to put it

class ImageConversionJob
  class << self
    def queue
      "default"
    end

    def work
      # convert some kind of image here
    end
    alias_method :perform, :work # the old API takes perform, but the new one will use work
  end
end

Next, we need to procrastinate! Let's put your job on the queue:

Resque.enqueue ImageConversionJob

Presumably, whenever resque 2.0 comes out in the not-so-distant future, we'd be able to do Resque.new and whatnot, but for now, this gist is here to hopefully save folks today some time and butt hurt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment