This project is archived and is in readonly mode.

#4749 ✓resolved
John Firebaugh

ActionController::UrlWriter removed without deprecation

Reported by John Firebaugh | June 1st, 2010 @ 09:25 PM

Including ActionController::UrlWriter in your class was a documented way to get access to named route helpers in 2.3.x. It's gone in beta3 without a deprecation.

It originally had a deprecation in action_controller/deprecations.rb, which was commented out in 226dfc2681c98deaf14e4ae82e973d1d5caedd68 and then removed entirely in 8689989a52fb673650c45322f060093678c6b91e (although action_controller.rb still has an autoload for it).

Comments and changes to this ticket

  • Wincent Colaiuta

    Wincent Colaiuta June 15th, 2010 @ 09:03 PM

    Any idea on what the replacement for this is?

    Back in Rails 2 I found that my sweepers didn't have access to named URL helper methods when running under the test environment. So I got around this by doing:

    include ActionController::UrlWriter
    

    in my sweepers.

    Under Rails 3 I observe the same behaviour: named URL helper methods don't work in sweepers (they all return nil). I think this is because some method_missing magic is going on in actionpack/lib/action_controller/caching/sweeping.rb:

    def method_missing(method, *arguments, &block)
      return if @controller.nil?
      @controller.__send__(method, *arguments, &block)
    end
    

    For some reason, under the test environment, the helper methods are not included and there is no real @controller object here when the sweeper is called. So a sweeper which does something like:

    expire_page(product_path(product) + '.html')

    Ends up evaluating it like this:

    expire_path(nil + '.html')

    Which obviously doesn't work.

    No idea why, but under development and production environments, the helper methods are included, and so the "method_missing" stuff never kicks in and calls to methods like "product_path(product)" work fine in the sweeper.

    So this seems like long-standing behavior, and under Rails 2 I could work around it by explicitly including UrlWriter. Wondering what I should be doing to get the same kind of workaround in Rails 3.

  • Wincent Colaiuta

    Wincent Colaiuta June 15th, 2010 @ 09:11 PM

    Ok, via some lucky grepping found this:

    # this is the Rails 2 way
    include ActionController::UrlWriter
    
    # this is the Rails 3 equivalent
    include Rails.application.routes.url_helpers
    
  • John Firebaugh

    John Firebaugh August 11th, 2010 @ 12:48 AM

    • Assigned user set to “Yehuda Katz (wycats)”

    Yehuda added a deprecation; this ticked should be resolved.

    http://github.com/rails/rails/commit/84703be5ffe7d94fd33bfbdb45cb0b...

  • José Valim

    José Valim August 12th, 2010 @ 02:52 PM

    • State changed from “new” to “resolved”
    • Importance changed from “” to “Low”

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="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Pages