diff --git a/actionpack/lib/action_controller/metal/strong_parameters.rb b/actionpack/lib/action_controller/metal/strong_parameters.rb index 510cb353b493f..8532b21d94b02 100644 --- a/actionpack/lib/action_controller/metal/strong_parameters.rb +++ b/actionpack/lib/action_controller/metal/strong_parameters.rb @@ -337,6 +337,8 @@ def each_pair(&block) @parameters.each_pair do |key, value| yield [key, convert_hashes_to_parameters(key, value)] end + + self end alias_method :each, :each_pair diff --git a/actionpack/test/controller/parameters/accessors_test.rb b/actionpack/test/controller/parameters/accessors_test.rb index db9359876c9a6..25a9cee0109e3 100644 --- a/actionpack/test/controller/parameters/accessors_test.rb +++ b/actionpack/test/controller/parameters/accessors_test.rb @@ -20,6 +20,14 @@ class ParametersAccessorsTest < ActiveSupport::TestCase ) end + test "each returns self" do + assert_same @params, @params.each { |_| _ } + end + + test "each_pair returns self" do + assert_same @params, @params.each_pair { |_| _ } + end + test "[] retains permitted status" do @params.permit! assert_predicate @params[:person], :permitted?