If you just added the lib / tasks / resque.rake file and did not change your Rakefile, you will still load the Rails environment when you call rake resque: work. Try this for Rakefile:
unless ENV['RESQUE_WORKER'] == 'true' require File.expand_path('../config/application', __FILE__) My::Application.load_tasks else ROOT_PATH = File.expand_path("..", __FILE__) load File.join(ROOT_PATH, 'lib/tasks/resque.rake') end
And then this is for your resque.rake file:
require "resque/tasks" task "resque:setup" do raise "Please set your RESQUE_WORKER variable to true" unless ENV['RESQUE_WORKER'] == "true" root_path = "#{File.dirname(__FILE__)}/../.." require "#{root_path}/app/workers/myworker.rb" end
Then call rake resque:work RESQUE_WORKER=true
source share