This project is archived and is in readonly mode.

#152 ✓resolved
Tom Adams

Routing optimisations break plugins that use ActionController::Base.default_url_options

Reported by Tom Adams | May 9th, 2008 @ 07:35 AM

The routing optimisations added in (trac) ticket 9450 [1] appear to break plugins [2] that use ActionController::Base.default_url_options to change generated URLs. For example secure_actions [2] turns http links into https links using this method.

Basically, the dynamically generated methods for named routes @action_controller_path@, @action_controller_url@, etc. when invoked with no arguments, use the routing optimisations, returning /controller/action/ etc. directly without going through @ActionView::Helpers::UrlHelper.url_for@, calling @ActionController::Base.url_for@, which in turn calls ActionController::Base.default_url_options. Plugins that use ActionController::Base.default_url_options to provide additional semantics to URL generation are thus not invoked.

If the optimisations are turned off [3] the plugin is invoked as expected. Apart from turning off the optimisations, there appears to be no other appropriate point (in the optimisation code) for plugins to hook into.

The Rails version this appears on is 2.0.2 (taken from the 2.0.2 SVN tag.


[2] e.g. secure_actions

[3] config.action_controller.perform_caching = false

Comments and changes to this ticket

  • Tom Adams

    Tom Adams May 9th, 2008 @ 07:38 AM

    Apologies for the nasty formatting, I see it's not too much like TextTile...

  • Cheah Chu Yeow

    Cheah Chu Yeow May 9th, 2008 @ 11:34 AM

    Is this still broken in the latest revision of Rails (on Github)? If not, you may be interested in looking at

  • Tom Adams

    Tom Adams May 13th, 2008 @ 05:28 AM

    It appears that it is still broken, however I've been unable to reconfirm this, it could be some screwy settings on my behalf. I've checked the code in the patch attached to the referenced ticket though, and it looks fine, however I've not had the chance to debug it (I'm having gem issues with activerecord versions).

  • DHH

    DHH May 31st, 2008 @ 10:40 PM

    • State changed from “new” to “resolved”

    default_url_options are not used for named routes. If you need that to happen, you can do:

    config.action_controller.optimise_named_routes = false

  • Tom Adams

    Tom Adams June 1st, 2008 @ 12:06 AM

    I don't think this is the point, the issue was that it was working this way before, but no longer. Plugins (and hence project code) that depended on this behaviour no longer works after upgrading. At the very least this deserves a prominent notice in the doco.

  • DHH

    DHH June 2nd, 2008 @ 06:38 PM

    I think that's fair. Please do add a docrails patch with this information where you'd expect to find it yourself if you were looking. Thanks!

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=""></a>

People watching this ticket

Referenced by