Class: Sidekiq::Middleware::Server::ActiveRecord

Inherits:
Object
  • Object
show all
Defined in:
lib/sidekiq/middleware/server/active_record.rb

Instance Method Summary collapse

Constructor Details

#initializeActiveRecord

Returns a new instance of ActiveRecord.



7
8
9
10
11
12
13
# File 'lib/sidekiq/middleware/server/active_record.rb', line 7

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

Instance Method Details

#call(*args) ⇒ Object



15
16
17
18
19
# File 'lib/sidekiq/middleware/server/active_record.rb', line 15

def call(*args)
  yield
ensure
  ::ActiveRecord::Base.clear_active_connections!
end