Rails uninitialized constant Resque::Server

One of the most significant changes in my migration of a rails app from Rails 2.3.10 to rails 3.0.9 was the move from delayed_jobs to resque.

Resque is a Queue system that’s based on Redis, which is much faster and reduces the load on your database. Also we were experiencing some nasty deadlocks with delayed jobs that really broke our transactions and our backs.

I installed the gem and installed Redis on my development machine, mounted the Sinatra app on my rails app and navigated to the web view of resque.

Then, I saw this error:

RuntimeError at /resque/overview
ERR unknown command ‘server’
file: client.rb location: call line: 47

Which looked like that:

After doing some digging into the code (as I always do when I encountered a problem with a gem), I found that the version of the gem (resque) I was using called the “server” method on the redis instance which was not there any more.

Looking at the code for the new gem showed that the app is now using the property “redis_id” which looks like this:

<pre> def redis_id
# support 1.x versions of redis-rb
if redis.respond_to?(:server)
elsif redis.respond_to?(:nodes) # distributed
redis.nodes.map { |n| n.id }.join(‘, ‘)

Upgrading the gem to the newest version solved my problem and everything got back to normal.
So, if you encounter this issue, just upgrade the resque gem and you are all good.

The gem version I was using was “resque (1.8.2)”, now I am using “resque (1.18.2)”

As always, if this post was helpful, drop me a comment, I would love to hear.