defunkt/resque — Issue #471: Rails.application is nil
Author: mb-dev
Created: 2011-12-06 17:58:53+00:00
State: open

After updating to Ruby 1.9.3 I got this error when running resque:

undefined method `eager_load!' for nil:NilClass
/Users/cruisewise/.rvm/gems/ruby-1.9.3-p0@cruisewise/gems/resque-1.19.0/lib/resque/tasks.rb:47:in `block (2 levels) in '

Looking at tasks.rb I see this means that Rails.application can be nil. I found on this discussion:
https://github.com/freelancing-god/thinking-sphinx/issues/313#issuecomment-3000238

It would be better to have:
if defined?(Rails) && Rails.application

After changing it I no longer get the error and resque works.