aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/metal/strong_parameters.rb
diff options
context:
space:
mode:
authorEugene Kenny <elkenny@gmail.com>2017-05-10 23:48:46 +0100
committerEugene Kenny <elkenny@gmail.com>2017-05-10 23:48:46 +0100
commitfb0fae9747ceec065e75867ea83afb713a5b449b (patch)
tree781aedc15df9c301bc30e714a44d6748fd91edd6 /actionpack/lib/action_controller/metal/strong_parameters.rb
parent97bd56e674603529d96c6f6e85d695dd24208afb (diff)
downloadrails-fb0fae9747ceec065e75867ea83afb713a5b449b.tar.gz
rails-fb0fae9747ceec065e75867ea83afb713a5b449b.tar.bz2
rails-fb0fae9747ceec065e75867ea83afb713a5b449b.zip
Pass block in ActionController::Parameters#delete
In order to fully support the same interface as `Hash#delete`, we need to pass the block through to the underlying method, not just the key. This used to work correctly, but it regressed when `ActionController::Parameters` stopped inheriting from `Hash` in 5.0.
Diffstat (limited to 'actionpack/lib/action_controller/metal/strong_parameters.rb')
-rw-r--r--actionpack/lib/action_controller/metal/strong_parameters.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/actionpack/lib/action_controller/metal/strong_parameters.rb b/actionpack/lib/action_controller/metal/strong_parameters.rb
index 7864f9decd..20330b5091 100644
--- a/actionpack/lib/action_controller/metal/strong_parameters.rb
+++ b/actionpack/lib/action_controller/metal/strong_parameters.rb
@@ -666,8 +666,8 @@ module ActionController
# to key. If the key is not found, returns the default value. If the
# optional code block is given and the key is not found, pass in the key
# and return the result of block.
- def delete(key)
- convert_value_to_parameters(@parameters.delete(key))
+ def delete(key, &block)
+ convert_value_to_parameters(@parameters.delete(key, &block))
end
# Returns a new instance of <tt>ActionController::Parameters</tt> with only