diff --git a/lib/resque.rb b/lib/resque.rb index 19269e55c..709edf760 100644 --- a/lib/resque.rb +++ b/lib/resque.rb @@ -24,7 +24,6 @@ require 'resque/vendor/utf8_util' require 'resque/railtie' if defined?(Rails::Railtie) -require 'active_job/queue_adapters/resque_adapter' if defined?(ActiveJob) module Resque include Helpers diff --git a/lib/resque/railtie.rb b/lib/resque/railtie.rb index ea71e892c..2c8b615e8 100644 --- a/lib/resque/railtie.rb +++ b/lib/resque/railtie.rb @@ -6,5 +6,12 @@ class Railtie < Rails::Railtie # redefine ths task to load the rails env task "resque:setup" => :environment end + + initializer "resque.active_job" do + ActiveSupport.on_load(:active_job) do + require "active_job/queue_adapters/resque_adapter" + ActiveJob::Base.queue_adapter = :resque + end + end end end