aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/metal
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib/action_controller/metal')
-rw-r--r--actionpack/lib/action_controller/metal/conditional_get.rb58
-rw-r--r--actionpack/lib/action_controller/metal/strong_parameters.rb20
2 files changed, 41 insertions, 37 deletions
diff --git a/actionpack/lib/action_controller/metal/conditional_get.rb b/actionpack/lib/action_controller/metal/conditional_get.rb
index 12ef68ff26..3f37a6a618 100644
--- a/actionpack/lib/action_controller/metal/conditional_get.rb
+++ b/actionpack/lib/action_controller/metal/conditional_get.rb
@@ -18,8 +18,6 @@ module ActionController
# may want to add the current user id to be part of the etag to prevent authorized displaying
# of cached pages.
#
- # === Example
- #
# class InvoicesController < ApplicationController
# etag { current_user.try :id }
#
@@ -34,25 +32,28 @@ module ActionController
end
end
- # Sets the etag, last_modified, or both on the response and renders a
+ # Sets the etag, +last_modified+, or both on the response and renders a
# <tt>304 Not Modified</tt> response if the request is already fresh.
#
- # Parameters:
- # * <tt>:etag</tt>
- # * <tt>:last_modified</tt>
- # * <tt>:public</tt> By default the Cache-Control header is private, set this to true if you want your application to be cachable by other devices (proxy caches).
+ # === Parameters:
+ #
+ # * <tt>:etag</tt>.
+ # * <tt>:last_modified</tt>.
+ # * <tt>:public</tt> By default the Cache-Control header is private, set this to
+ # +true+ if you want your application to be cachable by other devices (proxy caches).
#
- # Example:
+ # === Example:
#
# def show
# @article = Article.find(params[:id])
- # fresh_when(:etag => @article, :last_modified => @article.created_at, :public => true)
+ # fresh_when(etag: @article, last_modified: @article.created_at, public: true)
# end
#
# This will render the show template if the request isn't sending a matching etag or
# If-Modified-Since header and just a <tt>304 Not Modified</tt> response if there's a match.
#
- # You can also just pass a record where last_modified will be set by calling updated_at and the etag by passing the object itself. Example:
+ # You can also just pass a record where +last_modified+ will be set by calling
+ # +updated_at+ and the etag by passing the object itself.
#
# def show
# @article = Article.find(params[:id])
@@ -81,22 +82,24 @@ module ActionController
head :not_modified if request.fresh?(response)
end
- # Sets the etag and/or last_modified on the response and checks it against
+ # Sets the +etag+ and/or +last_modified+ on the response and checks it against
# the client request. If the request doesn't match the options provided, the
# request is considered stale and should be generated from scratch. Otherwise,
# it's fresh and we don't need to generate anything and a reply of <tt>304 Not Modified</tt> is sent.
#
- # Parameters:
- # * <tt>:etag</tt>
- # * <tt>:last_modified</tt>
- # * <tt>:public</tt> By default the Cache-Control header is private, set this to true if you want your application to be cachable by other devices (proxy caches).
+ # === Parameters:
+ #
+ # * <tt>:etag</tt>.
+ # * <tt>:last_modified</tt>.
+ # * <tt>:public</tt> By default the Cache-Control header is private, set this to
+ # +true+ if you want your application to be cachable by other devices (proxy caches).
#
- # Example:
+ # === Example:
#
# def show
# @article = Article.find(params[:id])
#
- # if stale?(:etag => @article, :last_modified => @article.created_at)
+ # if stale?(etag: @article, last_modified: @article.created_at)
# @statistics = @article.really_expensive_call
# respond_to do |format|
# # all the supported formats
@@ -104,7 +107,8 @@ module ActionController
# end
# end
#
- # You can also just pass a record where last_modified will be set by calling updated_at and the etag by passing the object itself. Example:
+ # You can also just pass a record where +last_modified+ will be set by calling
+ # updated_at and the etag by passing the object itself.
#
# def show
# @article = Article.find(params[:id])
@@ -122,7 +126,7 @@ module ActionController
# def show
# @article = Article.find(params[:id])
#
- # if stale?(@article, :public => true)
+ # if stale?(@article, public: true)
# @statistics = @article.really_expensive_call
# respond_to do |format|
# # all the supported formats
@@ -134,18 +138,18 @@ module ActionController
!request.fresh?(response)
end
- # Sets a HTTP 1.1 Cache-Control header. Defaults to issuing a <tt>private</tt> instruction, so that
- # intermediate caches must not cache the response.
+ # Sets a HTTP 1.1 Cache-Control header. Defaults to issuing a +private+
+ # instruction, so that intermediate caches must not cache the response.
#
# expires_in 20.minutes
- # expires_in 3.hours, :public => true
- # expires_in 3.hours, :public => true, :must_revalidate => true
+ # expires_in 3.hours, public: true
+ # expires_in 3.hours, public: true, must_revalidate: true
#
# This method will overwrite an existing Cache-Control header.
# See http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html for more possibilities.
#
# The method will also ensure a HTTP Date header for client compatibility.
- def expires_in(seconds, options = {}) #:doc:
+ def expires_in(seconds, options = {})
response.cache_control.merge!(
:max_age => seconds,
:public => options.delete(:public),
@@ -157,9 +161,9 @@ module ActionController
response.date = Time.now unless response.date?
end
- # Sets a HTTP 1.1 Cache-Control header of <tt>no-cache</tt> so no caching should occur by the browser or
- # intermediate caches (like caching proxy servers).
- def expires_now #:doc:
+ # Sets a HTTP 1.1 Cache-Control header of <tt>no-cache</tt> so no caching should
+ # occur by the browser or intermediate caches (like caching proxy servers).
+ def expires_now
response.cache_control.replace(:no_cache => true)
end
diff --git a/actionpack/lib/action_controller/metal/strong_parameters.rb b/actionpack/lib/action_controller/metal/strong_parameters.rb
index 55cc62a15e..c9a81e4866 100644
--- a/actionpack/lib/action_controller/metal/strong_parameters.rb
+++ b/actionpack/lib/action_controller/metal/strong_parameters.rb
@@ -7,15 +7,15 @@ module ActionController
#
# params = ActionController::Parameters.new(a: {})
# params.fetch(:b)
- # # => ActionController::ParameterMissing: key not found: b
+ # # => ActionController::ParameterMissing: param not found: b
# params.require(:a)
- # # => ActionController::ParameterMissing: key not found: a
+ # # => ActionController::ParameterMissing: param not found: a
class ParameterMissing < KeyError
attr_reader :param # :nodoc:
def initialize(param) # :nodoc:
@param = param
- super("key not found: #{param}")
+ super("param not found: #{param}")
end
end
@@ -124,10 +124,10 @@ module ActionController
# # => {"name"=>"Francesco"}
#
# ActionController::Parameters.new(person: nil).require(:person)
- # # => ActionController::ParameterMissing: key not found: person
+ # # => ActionController::ParameterMissing: param not found: person
#
# ActionController::Parameters.new(person: {}).require(:person)
- # # => ActionController::ParameterMissing: key not found: person
+ # # => ActionController::ParameterMissing: param not found: person
def require(key)
self[key].presence || raise(ParameterMissing.new(key))
end
@@ -160,7 +160,7 @@ module ActionController
# }
# })
#
- # permitted = params.permit(person: [ :name, { pets: [ :name ] } ])
+ # permitted = params.permit(person: [ :name, { pets: :name } ])
# permitted.permitted? # => true
# permitted[:person][:name] # => "Francesco"
# permitted[:person][:age] # => nil
@@ -212,7 +212,7 @@ module ActionController
#
# params = ActionController::Parameters.new(person: { name: 'Francesco' })
# params.fetch(:person) # => {"name"=>"Francesco"}
- # params.fetch(:none) # => ActionController::ParameterMissing: key not found: none
+ # params.fetch(:none) # => ActionController::ParameterMissing: param not found: none
# params.fetch(:none, 'Francesco') # => "Francesco"
# params.fetch(:none) { 'Francesco' } # => "Francesco"
def fetch(key, *args)
@@ -269,7 +269,7 @@ module ActionController
end
end
- # == Strong Parameters
+ # == Strong \Parameters
#
# It provides an interface for protecting attributes from end-user
# assignment. This makes Action Controller parameters forbidden
@@ -290,9 +290,9 @@ module ActionController
# end
#
# # This will pass with flying colors as long as there's a person key in the
- # # parameters, otherwise it'll raise a ActionController::MissingParameter
+ # # parameters, otherwise it'll raise an ActionController::MissingParameter
# # exception, which will get caught by ActionController::Base and turned
- # # into that 400 Bad Request reply.
+ # # into a 400 Bad Request reply.
# def update
# redirect_to current_account.people.find(params[:id]).tap { |person|
# person.update_attributes!(person_params)