diff options
author | Aditya <aditya@sublucid.com> | 2008-11-23 15:17:03 -0500 |
---|---|---|
committer | Aditya <aditya@sublucid.com> | 2008-11-23 15:17:03 -0500 |
commit | d67adf1e33b5ef93c7d414f87bdd68787297dd2f (patch) | |
tree | ac2070591533d1f3cfe1e1f3ecb7d719c2c58c68 /railties | |
parent | f3ac3fafbc6146337592c2dd4a37e5eb06912757 (diff) | |
download | rails-d67adf1e33b5ef93c7d414f87bdd68787297dd2f.tar.gz rails-d67adf1e33b5ef93c7d414f87bdd68787297dd2f.tar.bz2 rails-d67adf1e33b5ef93c7d414f87bdd68787297dd2f.zip |
Update with globally keyed fragments
Diffstat (limited to 'railties')
-rw-r--r-- | railties/doc/guides/source/caching_with_rails.txt | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/railties/doc/guides/source/caching_with_rails.txt b/railties/doc/guides/source/caching_with_rails.txt index 7cef6bf060..16dac19e08 100644 --- a/railties/doc/guides/source/caching_with_rails.txt +++ b/railties/doc/guides/source/caching_with_rails.txt @@ -176,7 +176,25 @@ and you can expire it using the `expire_fragment` method, like so: [source, ruby] ----------------------------------------------------- -expire_fragment(:controller => 'producst', :action => 'recent', :action_suffix => 'all_products) +expire_fragment(:controller => 'products', :action => 'recent', :action_suffix => 'all_products) +----------------------------------------------------- + +If you don't want the cache block to bind to the action that called it, You can +also use globally keyed fragments by calling the cache method with a key, like +so: + +[source, ruby] +----------------------------------------------------- +<% cache(:key => ['all_available_products', @latest_product.created_at].join(':')) do %> + All available products: +----------------------------------------------------- + +This fragment is then available to all actions in the ProductsController using +the key and can be expired the same way: + +[source, ruby] +----------------------------------------------------- +expire_fragment(:key => ['all_available_products', @latest_product.created_at].join(':')) ----------------------------------------------------- [More: more examples? description of fragment keys and expiration, etc? pagination?] |