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.

App routes.rb not loaded when both engine and inflections present

#1970

config/routes.rb is not loaded in an app where an engine plugin with a config/routes.rb is present and config/initializers/inflections.rb contains a ActiveSupport::Inflector.inflections block.

In development mode the plugin routes always get loaded and the application routes only if the app routes.rb has a higher modification date then the plugin file.

In production mode the app routes never get loaded at all.

I've attached a test project, this problem occur with 2.3 RC1 and the current master.

To see this in action: * open test project * run touch vendor/plugins/testplugin/config/routes.rb * run script/server and open http://localhost:3000, a Routing Error occurs. * run touch config/routes.rb * open http://localhost:3000, and the map.root in the app routes is used.

Then without inflections: * comment the contents of config/initializers/inflections.rb * run touch vendor/plugins/testplugin/config/routes.rb * open http://localhost:3000, and the map.root in the app routes is used.

Reported by Thijs · February 14th, 2009 @ 01:06 PM

State: committed
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. Thijs
    Thijs
    • Tag changed from engines, routing to 2.3, engines, routing

    I digged in a little deeper and found the cause of this issue: initialize_routing in railties/lib/initializer.rb calls the reload method without a bang.

    The reload method in ActionController::Routing::RouteSet checks the last modification date of the route files and this halts the reloading of the routes if they're older than @routes_last_modified.

    Because the inflections calls the reload! method, I think before initialize_routing is called, initialize_routing messes up the routes in this scenario.

    I don't think I fully understand what's causing this exactly, but this problem can be fixed by changing line 495 of railties/lib/initializer.rb from:

    ActionController::Routing::Routes.reload

    to:

    ActionController::Routing::Routes.reload!

    February 14th, 2009 @ 02:20 PM

  2. DHH
    DHH
    • Milestone cleared.

    February 14th, 2009 @ 02:54 PM

  3. Repository
    Repository
    • State changed from new to committed

    (from [b61cad6ae140bc71c6a74b22c75e886b41154b0a]) Ensure that the app routes file is loaded even when engines are in play (Thjis) [#1970 state:committed] http://github.com/rails/rails/co...

    February 22nd, 2009 @ 03:04 PM

  4. bingbing