提交 700c5583 编写于 作者: Y yuuji.yaginuma

call `.to_h` to avoid using deprecated method

`ActionController::Parameters#merge` call `HashWithIndifferentAccess#merge`.
In addition, it calls `HashWithIndifferentAccess#update` from
`HashWithIndifferentAccess#merge`,  where it is called the `#to_hash` of argument.
But `ActionController::Parameters#to_hash` is deprecated, warning message is
displayed.
To avoid this, modify to convert object to `Hash`.

Fixes #26415
上级 06658f1d
......@@ -578,7 +578,7 @@ def values_at(*keys)
# +other_hash+ merges into current hash.
def merge(other_hash)
new_instance_with_inherited_permitted_status(
@parameters.merge(other_hash)
@parameters.merge(other_hash.to_h)
)
end
......
......@@ -237,6 +237,13 @@ def walk_permitted(params)
assert @params.merge(a: "b").permitted?
end
test "merge with parameters" do
other_params = ActionController::Parameters.new(id: "1234").permit!
merged_params = @params.merge(other_params)
assert merged_params[:id]
end
test "modifying the parameters" do
@params[:person][:hometown] = "Chicago"
@params[:person][:family] = { brother: "Jonas" }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册