Forum: Rails deployment expire_fragment Strange behavior

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
71ee1809f53df0a2b4dac0530f630933?d=identicon&s=25 Richard Schneeman (snowmaninthesun)
on 2008-11-24 06:05
I'm following railscasts tutorial on fragment caching, everything works
great except for the sweepers. When i put expire_fragment(%r{.*})
directly in my controller, i can expire my fragments with wonderful
ease. Yet when i write a nice little sweeper like this code block,
nothing gets expired (the puts have been added in for troubleshooting):

class PhraseSweeper < ActionController::Caching::Sweeper
    observe Phrase

  def after_update(phrase)
    expire_cache(phrase)
  end

  def expire_cache(phrase)
    puts "=====This Is Activated Via expire_cache(phrase) "
    puts expire_fragment(%r{.*}).class
    expire_fragment(%r{.*})
  end
end

I put this put it in apps/sweepers, and initialize the folder under
environment.rb. When i update my phrase model I get this in my console:

=====This Is Activated Via expire_cache(phrase)
NilClass
=====This Is Activated Via expire_cache(phrase)
NilClass

Yet when i have the expire_fragment called via my controller i get this
in the console:

======This is called via the controller======
Hash

So, my sweeper folder is getting initialized, and the code is running on
update, but for some reason the puts are called twice, and the
expire_fragment doesn't work at all. Rails 2.1.0 Ruby 1.8.6. Any
suggestions??
71ee1809f53df0a2b4dac0530f630933?d=identicon&s=25 Richard Schneeman (snowmaninthesun)
on 2008-11-24 06:10
Sorry, wrong forum...re-posted under 'rails'
This topic is locked and can not be replied to.