article_sweeper.rb
来自「ruby on rails web敏捷开发之路第二版 源代码」· RB 代码 · 共 38 行
RB
38 行
#---# Excerpted from "Agile Web Development with Rails, 2nd Ed."# We make no guarantees that this code is fit for any purpose. # Visit http://www.pragmaticprogrammer.com/titles/rails2 for more book information.#---class ArticleSweeper < ActionController::Caching::Sweeper observe Article # If we create a new article, the public list of articles must be regenerated def after_create(article) expire_public_page end # If we update an existing article, the cached version of that article is stale def after_update(article) expire_article_page(article.id) end # Deleting a page means we update the public list and blow away the cached article def after_destroy(article) expire_public_page expire_article_page(article.id) end private def expire_public_page expire_page(:controller => "content", :action => 'public_content') end def expire_article_page(article_id) expire_action(:controller => "content", :action => "premium_content", :id => article_id) endend
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?