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

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

[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 http://rails.lighthouseapp.com/p....

  • 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!

Please Login or create a free account to add a new comment.

You can update this ticket by sending an email to from your email client. (help)

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Source available from github

The Git repository resides at http://github.com/rails

Check out the current development trunk (Edge Rails) with:

git clone git://github.com/rails/rails.git

Creating or reviewing a patch

See the contributor guide.

Creating a feature request

Please don't. If you want a new feature in Rails, you'll have to pull up your sleeves and get busy yourself. Or convince someone else to do it. See the contributor guide on how to get going. But posting them here is just going to lead to ticket root.

Creating a bug report

When creating a bug report, be sure to include as much relevant information as possible. Post the code sample that causes the problem. Preferably, alter the unit tests and show through either changed or added tests how the expected behavior is not occuring.

Security vulnerabilities should be reported via an email to security@rubyonrails.org, do not use trac for reporting security vulnerabilities. All content in trac is publicly available as soon as it is posted.

Then don't get your hopes up. Unless you have a "Code Red, Mission Critical, The World is Coming to an End" kinda bug, you're creating this ticket in the hope that others with the same problem will be able to collaborate with you on solving it. Do not expect that the ticket automatically will see any activity or that others will jump to fix it. Creating a ticket like this is mostly to help yourself start on the path of fixing the problem and for others to sign on to with a "I'm having this problem too".

Shared Ticket Bins

People watching this ticket