This project is archived and is in readonly mode.
ActionController::UrlWriter removed without deprecation
-
Wincent Colaiuta
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::UrlWriterin 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) endFor 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
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
- 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
- State changed from new to resolved
- Importance changed from to Low