Skip to content

Commit

Permalink
add cache_if and cache_unless on caching doc
Browse files Browse the repository at this point in the history
  • Loading branch information
acapilleri committed May 31, 2013
1 parent 48ac592 commit 861ec91
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions guides/source/caching_with_rails.md
Expand Up @@ -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
Expand Down

0 comments on commit 861ec91

Please sign in to comment.