aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael França <rafaelmfranca@gmail.com>2018-05-18 13:49:46 -0400
committerGitHub <noreply@github.com>2018-05-18 13:49:46 -0400
commitfc5a69def4b605576a13f6560a1ea6a467e9e851 (patch)
tree0a64c6481ee95085887c8caf13477943f54f7108
parenta213ac360f104d7ba6e9395cd9fdcb8e212a054e (diff)
parent8d5e0d3f5b9a81efbea2db42de70f0b34eed6e31 (diff)
downloadrails-fc5a69def4b605576a13f6560a1ea6a467e9e851.tar.gz
rails-fc5a69def4b605576a13f6560a1ea6a467e9e851.tar.bz2
rails-fc5a69def4b605576a13f6560a1ea6a467e9e851.zip
Merge pull request #32925 from Linuus/fix/actioncontroller-params-fetch-docs
Fix documentation for ActionController::Params#fetch
-rw-r--r--actionpack/lib/action_controller/metal/strong_parameters.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/actionpack/lib/action_controller/metal/strong_parameters.rb b/actionpack/lib/action_controller/metal/strong_parameters.rb
index 5a06bf86e3..46c0e80194 100644
--- a/actionpack/lib/action_controller/metal/strong_parameters.rb
+++ b/actionpack/lib/action_controller/metal/strong_parameters.rb
@@ -560,12 +560,14 @@ module ActionController
# Returns a parameter for the given +key+. If the +key+
# can't be found, there are several options: With no other arguments,
# it will raise an <tt>ActionController::ParameterMissing</tt> error;
- # if more arguments are given, then that will be returned; if a block
+ # if a second argument is given, then that is returned (converted to an
+ # instance of ActionController::Parameters if possible); if a block
# is given, then that will be run and its result returned.
#
# params = ActionController::Parameters.new(person: { name: "Francesco" })
# params.fetch(:person) # => <ActionController::Parameters {"name"=>"Francesco"} permitted: false>
# params.fetch(:none) # => ActionController::ParameterMissing: param is missing or the value is empty: none
+ # params.fetch(:none, {}) # => <ActionController::Parameters {} permitted: false>
# params.fetch(:none, "Francesco") # => "Francesco"
# params.fetch(:none) { "Francesco" } # => "Francesco"
def fetch(key, *args)