From 6d7f35ecb1ab6d58bb81ecbf5ff18009fb002425 Mon Sep 17 00:00:00 2001 From: "yuuji.yaginuma" Date: Tue, 18 Oct 2016 08:17:54 +0900 Subject: add `ActionController::Parameters#merge!` This method has the same behavior as `Hash#merge!`, returns current `ActionController::Parameters`. --- actionpack/lib/action_controller/metal/strong_parameters.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'actionpack/lib/action_controller/metal/strong_parameters.rb') diff --git a/actionpack/lib/action_controller/metal/strong_parameters.rb b/actionpack/lib/action_controller/metal/strong_parameters.rb index b64617d084..9df67d4be1 100644 --- a/actionpack/lib/action_controller/metal/strong_parameters.rb +++ b/actionpack/lib/action_controller/metal/strong_parameters.rb @@ -573,6 +573,13 @@ module ActionController ) end + # Returns current ActionController::Parameters instance which + # +other_hash+ merges into current hash. + def merge!(other_hash) + @parameters.merge!(other_hash.to_h) + self + end + # This is required by ActiveModel attribute assignment, so that user can # pass +Parameters+ to a mass assignment methods in a model. It should not # matter as we are using +HashWithIndifferentAccess+ internally. -- cgit v1.2.3