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.

Allow Engines routes order to be defined (map.from_plugin)

#2408

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 Add an API for plugins to register routes 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 Add an API for plugins to register routes 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 Add an API for plugins to register routes

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.

Reported by Marian Rudzynski · April 3rd, 2009 @ 02:30 PM

State: invalid
Milestone: 2.x
Assigned to: nobody
Importance: none

Activity

  1. CancelProfileIsBroken
    CancelProfileIsBroken
    • State changed from new to invalid

    Happy to reopen if you have a patch. Otherwise, falls under "Creating a feature request: please don't".

    April 3rd, 2009 @ 02:51 PM

  2. James Adam
    James Adam

    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 Add an API for plugins to register routes, and would appreciate your feedback there.

    May 1st, 2009 @ 08:48 PM

  3. Roger
    Roger

    perhaps an option like

    Rails::Initializer.run do |config|
    config.do_not_load_plugin_routes = true end

    might be enough, then people can later do something like
    load 'vendor/plugins/plugin_name/config/routes.rb'
    to have control of route loading

    ?

    May 15th, 2009 @ 08:05 PM