I recently came across this deprecation warning
DEPRECATION WARNING: Method size is deprecated and will be removed in Rails 5.1, as
ActionController::Parameters
no longer inherits from hash. Using this deprecated behavior exposes potential security problems. If you continue to use this method you may be creating a security vulnerability in your app that can be exploited.
Params looked like this:
<ActionController::Parameters { "objects" =>
<ActionController::Parameters {
"0"=>{"priority"=>"24", "style"=>"three_pictures"},
"1"=>{"priority"=>"24", "style"=>"three_pictures"},
"2"=>{"priority"=>"24", "style"=>"three_pictures"}
} permitted: false> } permitted: false>
And I tried to find the size of objects
like this:
params[:objects].size
And then I tried the same thing with length
and count
, which results in the same warning. What would be the work around for this? .keys.length
is something that works, but is this the correct way to do it or am I missing something here?
params to hash
usingto_h
and access those methods. – YokelTo access the parameters in the object you can add to_h to the parameters:
– Yokel