mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
23 lines
609 B
Ruby
23 lines
609 B
Ruby
# frozen_string_literal: true
|
|
module Sidekiq
|
|
module Middleware
|
|
module Server
|
|
class ActiveRecord
|
|
|
|
def initialize
|
|
# With Rails 5+ we must use the Reloader **always**.
|
|
# The reloader handles code loading and db connection management.
|
|
if defined?(::Rails) && ::Rails::VERSION::MAJOR >= 5
|
|
raise ArgumentError, "Rails 5 no longer needs or uses the ActiveRecord middleware."
|
|
end
|
|
end
|
|
|
|
def call(*args)
|
|
yield
|
|
ensure
|
|
::ActiveRecord::Base.clear_active_connections!
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|