I am having a bit of difficulty with ActiveJob in Rails 4.2 and Resque.
I've installed redis and I've added resque and resque-scheduler to my Gemfile.
I've created a test job - it is just the generated file
rails g job test
but I keep getting errors about ActiveJob not defined
NameError: uninitialized constant ActiveJob
or missing method when I switch the adapter like this
config.active_job.queue_adapter = :resque
I get this error
/usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.0.beta1/lib/rails/railtie/configuration.rb:95:in `method_missing': undefined method `active_job' for #<Rails::Application::Configuration:0x007f97ba98a5b8> (NoMethodError)
I've even looked at the source code but I have no idea. It is just calling super.
https://github.com/rails/rails/blob/master/railties/lib/rails/railtie/configuration.rb#L95
What I am missing? Why doesn't the queue adapter work? Does anyone know how to fix this?
I turns out that I had selected which frameworks I was using.
# config/application.rb
require "active_model/railtie"
require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "action_view/railtie"
require "sprockets/railtie"
The way to fix it, is to add the Active Job framework in the application.rb file.
require "active_job/railtie"
Or to load all of Rails
require 'rails/all'
This seems to be working now.