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/metal
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
..
conditional_get.rb Accept a collection in fresh_when and stale? 2015-02-10 17:08:44 -08:00
cookies.rb
data_streaming.rb
etag_with_template_digest.rb
exceptions.rb
flash.rb
force_ssl.rb
head.rb
helpers.rb
http_authentication.rb Fixed undefined method error when doing authentication. 2015-01-24 07:18:45 +08:00
implicit_render.rb
instrumentation.rb
live.rb
mime_responds.rb Remove unused require 2015-01-04 18:26:36 -02:00
params_wrapper.rb
rack_delegation.rb Add ActionController#build_with_env 2015-01-22 00:26:06 +03:00
redirecting.rb
renderers.rb
rendering.rb Add ActionController::Base.render 2015-01-22 01:02:13 +03:00
request_forgery_protection.rb Add prepend option to protect_from_forgery. 2015-01-08 19:47:19 +01:00
rescue.rb
streaming.rb
strong_parameters.rb
testing.rb
url_for.rb