Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

When a nil param value arrives in place of an expected hash, return

:key => nil, not simply nil.

Prior:

(rdb:1) params
{"book"=>nil}
(rdb:1) params.permit(book: { genre: :type })
nil

Now:

(rdb:1) params
{"book"=>nil}
(rdb:1) params.permit(book: { genre: :type })
{"book"=>nil}

Conflicts:

	lib/action_controller/parameters.rb
  • Loading branch information...
commit e769c6e063f958d974c33329e0e649135dd6b64a 1 parent 7ac4408
@bjhess bjhess authored
View
2  lib/action_controller/parameters.rb
@@ -60,8 +60,6 @@ def permit(*filters)
expanded_filter = expand_regex_filters(filter)
self.slice(*expanded_filter.keys).each do |key, value|
- return unless value
-
key = key.to_sym
params[key] = each_element(value) do |value|
View
8 test/nested_parameters_test.rb
@@ -77,4 +77,12 @@ class NestedParametersTest < ActiveSupport::TestCase
permitted = params.permit book: { genre: :type }
assert_nil permitted[:book][:genre]
end
+
+ test "nil param value that should be a hash" do
+ params = ActionController::Parameters.new({
+ book: nil
+ })
+ permitted = params.permit book: { genre: :type}
+ assert_nil permitted[:book]
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.