Class: CmsContentSweeper

Inherits:
ActionController::Caching::Sweeper
  • Object
show all
Defined in:
app/sweepers/cms_content_sweeper.rb

Instance Method Summary collapse

Instance Method Details

#after_destroy(record) ⇒ Object



8
9
10
# File 'app/sweepers/cms_content_sweeper.rb', line 8

def after_destroy(record)
  delete_all_cached_pages
end

#after_save(record) ⇒ Object



4
5
6
# File 'app/sweepers/cms_content_sweeper.rb', line 4

def after_save(record)
  delete_all_cached_pages
end

#delete_all_cached_pagesObject



12
13
14
15
16
17
18
19
20
# File 'app/sweepers/cms_content_sweeper.rb', line 12

def delete_all_cached_pages
  # expire home page
  expire_page :controller => 'cms/content', :action => 'show', :content_path => nil
  
  # expire all other pages
  CmsPage.select([ :id, :path ]).find_each do |page|
    expire_page :controller => 'cms/content', :action => 'show', :content_path => page.path.split('/')
  end
end