aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authorAditya <aditya@sublucid.com>2008-11-23 15:17:03 -0500
committerAditya <aditya@sublucid.com>2008-11-23 15:17:03 -0500
commitd67adf1e33b5ef93c7d414f87bdd68787297dd2f (patch)
treeac2070591533d1f3cfe1e1f3ecb7d719c2c58c68 /railties
parentf3ac3fafbc6146337592c2dd4a37e5eb06912757 (diff)
downloadrails-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.txt20
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?]