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 ``` |
||
---|---|---|
.. | ||
caching | ||
metal | ||
railties | ||
base.rb | ||
caching.rb | ||
log_subscriber.rb | ||
metal.rb | ||
middleware.rb | ||
railtie.rb | ||
renderer.rb | ||
test_case.rb |