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.

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

#152

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.

[1] http://dev.rubyonrails.org/ticke...

[2] e.g. secure_actions

[3] config.action_controller.perform_caching = false

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

State: resolved
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. Tom Adams
    Tom Adams

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

    May 9th, 2008 @ 07:38 AM

  2. Cheah Chu Yeow
    Cheah Chu Yeow

    Is this still broken in the latest revision of Rails (on Github)? If not, you may be interested in looking at http://rails.lighthouseapp.com/p....

    May 9th, 2008 @ 11:34 AM

  3. Tom Adams
    Tom Adams

    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).

    May 13th, 2008 @ 05:28 AM

  4. DHH
    DHH
    • 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

    May 31st, 2008 @ 10:40 PM

  5. Tom Adams
    Tom Adams

    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.

    June 1st, 2008 @ 12:06 AM

  6. DHH
    DHH

    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!

    June 2nd, 2008 @ 06:38 PM