diff options
author | Angelo capilleri <capilleri@yahoo.com> | 2013-05-31 17:59:06 +0200 |
---|---|---|
committer | Angelo capilleri <capilleri@yahoo.com> | 2013-05-31 17:59:06 +0200 |
commit | 861ec91e8c681302cec76d9bce278da829e85df1 (patch) | |
tree | 98af43abe01dee01d828cabd071a565fb4160004 /guides | |
parent | 48ac592bd9d1b1fb9e069f005b084d535941240e (diff) | |
download | rails-861ec91e8c681302cec76d9bce278da829e85df1.tar.gz rails-861ec91e8c681302cec76d9bce278da829e85df1.tar.bz2 rails-861ec91e8c681302cec76d9bce278da829e85df1.zip |
add cache_if and cache_unless on caching doc
Diffstat (limited to 'guides')
-rw-r--r-- | guides/source/caching_with_rails.md | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/guides/source/caching_with_rails.md b/guides/source/caching_with_rails.md index c0cbce81c5..1e196b0e42 100644 --- a/guides/source/caching_with_rails.md +++ b/guides/source/caching_with_rails.md @@ -104,6 +104,15 @@ This method generates a cache key that depends on all products and can be used i All available products: <% end %> ``` + +If you want to cache a fragment under certain condition you can use `cache_if` or `cache_unless` + +```erb +<% cache_if (condition, cache_key_for_products) do %> + All available products: +<% end %> +``` + You can also use an Active Record model as the cache key: ```erb |