mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
050fda0206
The methods `fresh_when` and `stale?` from ActionController::ConditionalGet accept a single record as a short form for a hash. For instance ```ruby def show @article = Article.find(params[:id]) fresh_when(@article) end ``` is just a short form for: ```ruby def show @article = Article.find(params[:id]) fresh_when(etag: @article, last_modified: @article.created_at) end ``` This commit extends `fresh_when` and `stale?` to also accept a collection of records, so that a short form similar to the one above can be used in an `index` action. After this commit, the following code: ```ruby def index @article = Article.all fresh_when(etag: @articles, last_modified: @articles.maximum(:created_at)) end ``` can be simply written as: ```ruby def index @article = Article.all fresh_when(@articles) end ``` |
||
---|---|---|
.. | ||
conditional_get.rb | ||
cookies.rb | ||
data_streaming.rb | ||
etag_with_template_digest.rb | ||
exceptions.rb | ||
flash.rb | ||
force_ssl.rb | ||
head.rb | ||
helpers.rb | ||
http_authentication.rb | ||
implicit_render.rb | ||
instrumentation.rb | ||
live.rb | ||
mime_responds.rb | ||
params_wrapper.rb | ||
rack_delegation.rb | ||
redirecting.rb | ||
renderers.rb | ||
rendering.rb | ||
request_forgery_protection.rb | ||
rescue.rb | ||
streaming.rb | ||
strong_parameters.rb | ||
testing.rb | ||
url_for.rb |