Skip to content
Browse files

add cache_if and cache_unless on caching doc

  • Loading branch information...
1 parent 48ac592 commit 861ec91e8c681302cec76d9bce278da829e85df1 @acapilleri acapilleri committed May 31, 2013
Showing with 9 additions and 0 deletions.
  1. +9 −0 guides/source/caching_with_rails.md
View
9 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

0 comments on commit 861ec91

Please sign in to comment.
Something went wrong with that request. Please try again.