1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/actionpack/lib/action_controller
claudiob 050fda0206 Accept a collection in fresh_when and stale?
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
```
2015-02-10 17:08:44 -08:00
..
caching Merge pull request #14137 from dasch/better-fragment-cache-instrumentation 2014-05-14 20:04:43 -03:00
metal Accept a collection in fresh_when and stale? 2015-02-10 17:08:44 -08:00
railties
base.rb Remove ActionController::HideActions (closes #18336) 2015-01-06 23:40:45 +03:00
caching.rb [ci skip] correct default cache store class 2014-08-13 18:56:03 +05:30
log_subscriber.rb Don't convert empty arrays to nils when deep munging params 2014-12-15 14:51:07 +00:00
metal.rb Add ActionController::Metal#set_request! 2015-01-21 23:53:38 +03:00
middleware.rb
railtie.rb Merge pull request #15933 from rafael/master 2014-06-27 18:16:52 -03:00
renderer.rb Speed up normalize_keys by removing dup step. 2015-01-22 17:35:19 +01:00
test_case.rb Merge pull request #18771 from kirs/deprecate-xhr 2015-02-05 18:27:47 -02:00