aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorschneems <richard.schneeman+foo@gmail.com>2018-08-30 09:33:15 -0500
committerschneems <richard.schneeman+foo@gmail.com>2018-08-30 11:03:22 -0500
commit11bcf952870630c41c2c21990d0935b639af532f (patch)
treefae4572e9744befdcbb3834224cf9373fa16a3cc /actionpack
parent5e86ee1195eaf2242a5fdd35fce3790260e5e826 (diff)
downloadrails-11bcf952870630c41c2c21990d0935b639af532f.tar.gz
rails-11bcf952870630c41c2c21990d0935b639af532f.tar.bz2
rails-11bcf952870630c41c2c21990d0935b639af532f.zip
[ci skip] Document permitted_scalar_filter
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_controller/metal/strong_parameters.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/actionpack/lib/action_controller/metal/strong_parameters.rb b/actionpack/lib/action_controller/metal/strong_parameters.rb
index 52664dd1fb..21859e5356 100644
--- a/actionpack/lib/action_controller/metal/strong_parameters.rb
+++ b/actionpack/lib/action_controller/metal/strong_parameters.rb
@@ -904,6 +904,16 @@ module ActionController
PERMITTED_SCALAR_TYPES.any? { |type| value.is_a?(type) }
end
+ # Adds existing keys to the params if their values are scalar.
+ #
+ # For example:
+ #
+ # puts self.keys #=> ["zipcode(90210i)"]
+ # params = {}
+ #
+ # permitted_scalar_filter(params, "zipcode")
+ #
+ # puts params.keys # => ["zipcode"]
def permitted_scalar_filter(params, key)
if has_key?(key) && permitted_scalar?(self[key])
params[key] = self[key]