Forum: Ruby on Rails Where did url_for go in my cache Sweeper

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Daniel G. (Guest)
on 2007-02-19 08:22

  Where oh, where did the url_for method go? I have a Sweeper that uses
url_for to generate new page caches whenever the model changes (kind of
active caching).
In this case I am using a custom method rather than Caching.cache_page,
since I want the page to cache all the time (ignoring the normal caching
The sweeper is being woken up just fine, but there is some strange
behaviour happening with the url_for method...

class PublishSweeper < ActionController::Caching::Sweeper
  observe Computer, Node, Program

  def after_save(record)
    puts self.inspect
    case record
      when Node
        write_cache(:controller=>"xml_server", :action=>"node",
      when Program
        write_cache(:controller=>"xml_server", :action=>"program",
  def write_cache(path)

In the first case (Node) url_for is available and returns what is
expected. However, in the second case (Program) url_for is nil (it's not
being called at all). The sweeper call backs are being initiated from
the different actions in the same controller, and apart from saving
different model types there's no other differences. Is there any obvious
reason that the method would disappear like this?? I'm stumped, any
ideas on what to look at (or better still a solution) would be


By the way the "puts self.inspect" in after_save shows the folling:
  when it *is not* working:

  when it *is* working:

Something fishy seems to be going on with the sweepers access to
This topic is locked and can not be replied to.