Module: ActionController::Caching::Pages

Defined in:
lib/cache_trasher.rb

Overview

CacheTrasher

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#trash_cache(supplied_path = "", options = {}) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/cache_trasher.rb', line 39

def trash_cache(supplied_path = "", options = {})
  return unless perform_caching
  
  path = case supplied_path
  when Hash
    # Note this part of the url_for documentation:
    # 
    # If the controller name begins with a slash no defaults are used:
    # url_for :controller => '/home'
    # In particular, a leading slash ensures no namespace is assumed. Thus, while url_for :controller => 'users' 
    # may resolve to Admin::UsersController if the current controller lives under that module, url_for :controller => '/users' 
    # ensures you link to ::UsersController no matter what.
    url_for(supplied_path.merge(:only_path => true, :skip_relative_url_root => true))
  when String
    supplied_path
  end
  
  self.class.trash_cache(path, options)
end