Calling expire_fragment within rails console

Bookmark this on Digg
Bookmark this on Delicious
Share on Facebook
Post to Google Buzz
Bookmark this on Yahoo Bookmark
Share on FriendFeed
[`tweetmeme` not found]

Today i want to expire a fragment cache in haml view:

-cache('taxonomy') do

So I enter in rails c production, but I found Rails.cache.exists?(‘taxonomy’) returned false.

expire_fragment doesn’t exist in ActionController::Caching::Sweeper. It can be found in ActionController::Base. The sweeper class uses method_missing to call the method from a controller instance.

ActionController::Base.new.expire_fragment(‘taxonomy’, options = nil) 

That’s why everything was fine when I used to expire through controllers and nothing happened when everything was called from an observer class or so, I just needed a controller instance and it worked.

def expire_cache_for(deal)
  @controller ||= ActionController::Base.new 
  expire_fragment('taxonomy')
end