views:

55

answers:

1

Hi,

We are using Rails 2.3.2, Ruby 1.8 & memcache.

In my Posts controller I have:

cache_sweeper Company::Caching::Sweepers::PostSweeper, :only => [:save_post]

I have created the following module:

module Company
  module Caching
    module Sweepers

      class PostSweeper < ActionController::Caching::Sweeper
        observe Post

        def after_save(post)
          Rails.cache.delete("post_" + post.permalink)
        end
      end

    end
  end
end

but when the save_post method is invoked, the cache is never deleted. Just hoping someone can see what I am doing wrong here. Thanks.

A: 

If the action in the controller is called save_post, your sweeper method should be called after_save_post(post).

fstephany