Forum: Rails deployment expire_fragment Strange behavior

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.
Richard S. (Guest)
on 2008-11-24 07: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)

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

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)
=====This Is Activated Via expire_cache(phrase)

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

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

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
Richard S. (Guest)
on 2008-11-24 07:10
Sorry, wrong under 'rails'
This topic is locked and can not be replied to.