This project is archived and is in readonly mode.
App routes.rb not loaded when both engine and inflections present
Reported by Thijs | February 14th, 2009 @ 01:06 PM
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.
Comments and changes to this ticket
-
Thijs February 14th, 2009 @ 02:20 PM
- 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!
-
DHH February 14th, 2009 @ 02:54 PM
- Milestone cleared.
-
Repository February 22nd, 2009 @ 03:04 PM
- 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...
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Attachments
Referenced by
- 1970 App routes.rb not loaded when both engine and inflections present (from [b61cad6ae140bc71c6a74b22c75e886b41154b0a]) Ensure ...