This project is archived and is in readonly mode.
Allow Engines routes order to be defined (map.from_plugin)
Reported by Marian Rudzynski | April 3rd, 2009 @ 02:30 PM | in 2.x
I just added "map.from_plugin" to the title so this can be found by people missing that functionality from Engines.
There should (must) be a way to define the order of routes set by a plugin. This has been proposed earlier in Ticket #329 and has been closed as duplicate for the current implementation -- that allows no ordering whatsoever and simply doesn't clear routes set by plugins (auto-loading their config/routes.rb file)
The way proposed in #329 might be sufficient but one could go all the way now by allowing plugins themselves to define their route positions, like so:
ActionController::Routing::Routes.draw do |map|
map.fourohfour '*path', :controller => 'errors', :action => 'show', :position => :last
map.fourohfour '*path', :controller => 'errors', :action => 'show', :position => :first
map.fourohfour '*path', :controller => 'errors', :action => 'show', :position => {:before => :root}
map.fourohfour '*path', :controller => 'errors', :action => 'show', :position => {:after => :root}
end
Making it more specific than that would be overkill, imho. All I am looking for right now, for example, is to place a catch-all route like above at the very end of routes. If one needs more specific placement, one should go with the approach of Ticket #329
Now I might actually go ahead and implement this in some fashion as I need it right now, so if there's no taker, I might have a patch up next week.
Comments and changes to this ticket
-
CancelProfileIsBroken April 3rd, 2009 @ 02:51 PM
- State changed from new to invalid
Happy to reopen if you have a patch. Otherwise, falls under "Creating a feature request: please don't".
-
James Adam May 1st, 2009 @ 08:48 PM
I'm not sure that controlling routes via a :position parameter is quite flexible enough, but regardless, I've added a patch which covers controlling plugin route positioning to Ticket #329, and would appreciate your feedback there.
-
Roger May 15th, 2009 @ 08:05 PM
perhaps an option like
Rails::Initializer.run do |config|
config.do_not_load_plugin_routes = true endmight be enough, then people can later do something like
load 'vendor/plugins/plugin_name/config/routes.rb'
to have control of route loading?
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>