Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

ActiveRecord middleware should be inserted before ActionDispatch::Cascade ?

#4493

Using rails 3 beta 3. I have a piece of metal code, and I think it's fair to assume that most users will use some ActiveRecord code in there to retrieve some data.

However, the metal code is run before the middleware ActiveRecord::ConnectionAdapters::ConnectionManagement. I.e., when something fails in the metal code, then the AR connection manager will not get the chance to do: ActiveRecord::Base.clear_active_connections!

I have a few other use cases where I find it would be more useful if middleware ActionDispatch::Cascade was sitting just before MyApp::Application.routes and after ActiveRecord::QueryCache and any other user defined middlewares.

Reported by Lawrence Pit · April 28th, 2010 @ 01:41 AM

State: resolved
Milestone: 3.0.2
Assigned to: José Valim José Valim
Importance: none

Activity

  1. Lawrence Pit
    Lawrence Pit

    Actually, just found out that all my middlewares are sitting before ActiveRecord::ConnectionAdapters::ConnectionManagement. Perhaps the position of ActionDispatch::Cascade should be unchanged, and instead ActiveRecord::ConnectionAdapters::ConnectionManagement (and ActiveRecord::QueryCache ?) should go in front of ActionDispatch::Cascade ?

    April 28th, 2010 @ 08:11 AM

  2. Jeremy Kemper
    Jeremy Kemper
    • Milestone cleared.
    • State changed from new to open
    • Assigned user set to José Valim

    April 28th, 2010 @ 04:57 PM

  3. José Valim
    José Valim

    Hey Lawrence, let's fix it but we need a test case first.
    What happens if clear_active_connections! is not called? What failure do you get?

    April 28th, 2010 @ 05:34 PM

  4. Repository
  5. Jeremy Kemper