Observer not clearing cache in Rails 2.3.2 - please help.
Posted
by Jason
on Stack Overflow
See other posts from Stack Overflow
or by Jason
Published on 2010-06-01T00:25:33Z
Indexed on
2010/06/01
0:33 UTC
Read the original article
Hit count: 262
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.
© Stack Overflow or respective owner