2010-06-01 31 views
1

我們正在使用Rails 2.3.2,Ruby 1.8 & memcache。觀察者未在Rails 2.3.2中清除緩存 - 請幫助

在我的職位控制器我有:

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

我創建了以下模塊:

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 

但調用save_post方法時,緩存不會被刪除。只希望有人能看到我在這裏做錯了什麼。謝謝。

回答

0

如果控制器中的操作被稱爲save_post,則清掃方法應該被稱爲after_save_post(post)

0

可能是你沒有在你的負載路徑

config.load_paths += %W(#{RAILS_ROOT}/app/models/cache) 

所在目錄是你掃墓位於加的清掃。