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.

Plugin routes override application routes

#2592

At the moment, plugin routes are loaded before application routes. This means that it's possible for a plugin to override anything defined in the application's routes.rb.

Here's a small patch to fix it - I've adopted what I believe is the simplest approach without considering how to split apart the route loading process.

Reported by James Adam · May 1st, 2009 @ 03:25 PM

State: stale
Milestone: 3.x
Assigned to: nobody
Importance: none

Activity

  1. Nick Quaranto
    Nick Quaranto

    +1 for this. During the process of converting Clearance to a Rails engine, we had to hack into the routes loading process so it was possible to override routes in the app's config/routes.rb with those set in the plugin.

    The hack is the first tip listed here: http://giantrobots.thoughtbot.co...

    May 1st, 2009 @ 04:21 PM

  2. adlongwell
    adlongwell

    +1 I'm working on a CMS plugin system that could really benefit from this.

    May 5th, 2009 @ 06:58 PM

  3. Dan Croak
  4. jbasdf
    jbasdf
    1. I've used the technique listed by here: Nick http://giantrobots.thoughtbot.com/2009/4/23/tips-for-writing-your-o.... It would be nice if that was the default.

    July 21st, 2009 @ 04:54 PM

  5. Jason Ronallo
    Jason Ronallo

    +1 We're running into this problem with the Blacklight plugin where different sites need the ability to override routes.

    September 11th, 2009 @ 07:54 PM

  6. Bess
    Bess

    +1 Fixing this would really help us out for Blacklight: http://projectblacklight.org

    September 11th, 2009 @ 08:43 PM

  7. Naomi Dushay
    Naomi Dushay

    +1 to fix this - plugin route overrides are broken without this fix.

    September 11th, 2009 @ 11:23 PM

  8. Francesc Esplugas
    Francesc Esplugas

    Maybe you want routes from the plugin to be loaded first or last. In my opinion there should be a convention to define which routes have to be defined at the beginning and which routes at the end.

    Are you sure you want your routes to be loaded at the end if you have the default routes active? Some people doesn't remove them.

    I've developed an engine called Typus (http://intraducibles.com/projects/typus) and a few months back some users complained about how routes worked because they where loaded after the routes of the application. Now routes are loaded normally with a :path_prefix and everything is working nice.

    September 13th, 2009 @ 07:06 PM

  9. Mark Turner
  10. Eric Davis
    Eric Davis

    +1 I'd like to see this as part of the core Rails because it makes building modular applications easier. I've built a small prototype of this as a plugin and it's working great with Redmine so far.

    http://github.com/edavis10/prepend_engine_routes

    Eric Davis

    September 15th, 2009 @ 12:55 AM

  11. Matt Mitchell
  12. Jeremy Kemper
    Jeremy Kemper
    • Milestone changed from 2.x to 3.x

    May 4th, 2010 @ 06:48 PM

  13. Santiago Pastorino
    Santiago Pastorino
    • State changed from new to open
    • Tag changed from 2.3.2, bug, engines, patch, plugin, route to 232, bug, engines, patch, plugin, route
    • Importance changed from to

    This issue has been automatically marked as stale because it has not been commented on for at least three months.

    The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.

    Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.

    February 2nd, 2011 @ 05:02 PM

  14. Santiago Pastorino
    Santiago Pastorino
    • State changed from open to stale

    February 2nd, 2011 @ 05:02 PM

  15. bingbing