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.

requires in metals choke on second request in development reloading mode

#2579

Metals aren't handles by the usual dependency handling of rails, since they are manually required in Rails::Rack::Metal


if metal = all_metals[requested_metal]
  require metal
  requested_metal.constantize
end

This means that if your metal depends on any constants in the Rails project, it will choke on the second request, since they will have been unloaded, but they don't get reloaded for the metal request.

If you try and force the load in metal, via a require of the Model/Module/etc, then you get a double require (and the associated warnings about redefining constants, if you have any defined in said Model), since it is loaded by both the metal and rails standard dependency loading. If you try using require_dependency you are back to square one of choking on the second development request.

I would consider just patching it to require_dependency metal, but I am not sure for the reason for it not being, and what low level assumptions there may be about it being "metal" and lower level than AS::Dependency.

Let me know if there is anything I can do to clarify this.

Reported by Tim Connor · April 28th, 2009 @ 10:42 PM

State: resolved
Milestone: 2.x
Assigned to: josh josh
Importance: none

Activity

  1. Tim Connor
    Tim Connor

    Not sure if this is the right solutions (didn't see where to put any tests for the rack level stuff), but this solves the problem for me:

    http://github.com/timocratic/rai...

    April 28th, 2009 @ 11:03 PM

  2. Tim Connor
    Tim Connor

    fyi, this does NOT break reloading for me with metal in dev mode, in fact it fixes it.

    May 5th, 2009 @ 12:01 AM

  3. josh
    josh
    • State changed from new to open

    I promise to get it in soon.

    May 5th, 2009 @ 12:48 AM

  4. Tim Connor
    Tim Connor

    No rush, I just noticed today that it actually did work right with dev mode reloading, on my set-up, despite bitsweat saying something about it not.

    You probably will want to verify that it works right on your end. ;)

    May 5th, 2009 @ 01:08 AM

  5. Repository
    Repository
    • State changed from open to resolved

    (from [49169f7a6ab2699c500032e6e14570512c674274]) fix problems with requires in metal choking under development reloading [#2579 requires in metals choke on second request in development reloading mode state:resolved]

    Signed-off-by: Joshua Peek josh@joshpeek.com http://github.com/rails/rails/co...

    May 5th, 2009 @ 02:18 AM

  6. Repository
    Repository

    (from [e3891601d137a400722cfd0f941b9195b0a8217b]) fix problems with requires in metal choking under development reloading [#2579 requires in metals choke on second request in development reloading mode state:resolved]

    Signed-off-by: Joshua Peek josh@joshpeek.com http://github.com/rails/rails/co...

    May 5th, 2009 @ 02:18 AM