1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

embed code example using backticks in caching guide

This commit is contained in:
Sergey Nartimov 2012-11-20 16:17:13 +03:00
parent 7521698c17
commit ceb1fd34a8

View file

@ -465,14 +465,14 @@ end
Instead of a options hash, you can also simply pass in a model, Rails will use the `updated_at` and `cache_key` methods for setting `last_modified` and `etag`:
<ruby>
```ruby
class ProductsController < ApplicationController
def show
@product = Product.find(params[:id])
respond_with(@product) if stale?(@product)
end
end
</ruby>
```
If you don't have any special response processing and are using the default rendering mechanism (i.e. you're not using respond_to or calling render yourself) then youve got an easy helper in fresh_when: