diff --git a/lib/que/adapters/active_record.rb b/lib/que/adapters/active_record.rb index b210da26..9b4333f2 100644 --- a/lib/que/adapters/active_record.rb +++ b/lib/que/adapters/active_record.rb @@ -63,7 +63,13 @@ def add_to_transaction private def checkout_activerecord_adapter(&block) - ::ActiveRecord::Base.connection_pool.with_connection(&block) + if defined?(::Rails.application.executor) + ::Rails.application.executor.wrap do + ::ActiveRecord::Base.connection_pool.with_connection(&block) + end + else + ::ActiveRecord::Base.connection_pool.with_connection(&block) + end end end end