Skip to content

Instantly share code, notes, and snippets.

@nicksieger
Created August 29, 2008 19:30
Show Gist options
  • Save nicksieger/8037 to your computer and use it in GitHub Desktop.
Save nicksieger/8037 to your computer and use it in GitHub Desktop.
diff --git a/actionpack/lib/action_controller/dispatcher.rb b/actionpack/lib/action_controller/dispatcher.rb
index bdae5f9..a6bac65 100644
--- a/actionpack/lib/action_controller/dispatcher.rb
+++ b/actionpack/lib/action_controller/dispatcher.rb
@@ -20,8 +20,10 @@ module ActionController
end
if defined?(ActiveRecord)
- before_dispatch { ActiveRecord::Base.verify_active_connections! }
to_prepare(:activerecord_instantiate_observers) { ActiveRecord::Base.instantiate_observers }
+ # Release database connections reserved by the current thread/request back
+ # to the connection pool.
+ after_dispatch { ActiveRecord::Base.clear_active_connections! }
end
after_dispatch :flush_logger if Base.logger && Base.logger.respond_to?(:flush)
@@ -141,6 +143,7 @@ module ActionController
ActiveRecord::Base.clear_reloadable_connections! if defined?(ActiveRecord)
end
+
def flush_logger
Base.logger.flush
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment