Skip to content

Commit 33e1a89

Browse files
authored
Merge pull request rails#47687 from hidde-jan/alias-parameters-except-as-without
Alias ActionController::Parameters except as without
2 parents 65115f7 + 603b5cd commit 33e1a89

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

actionpack/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
* Add `without` as an alias of `except` on `ActiveController::Parameters`.
2+
3+
*Hidde-Jan Jongsma*
4+
15
* Expand search field on `rails/info/routes` to also search **route name**, **http verb** and **controller#action**.
26

37
*Jason Kotchoff*

actionpack/lib/action_controller/metal/strong_parameters.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,7 @@ def slice!(*keys)
734734
def except(*keys)
735735
new_instance_with_inherited_permitted_status(@parameters.except(*keys))
736736
end
737+
alias_method :without, :except
737738

738739
# Removes and returns the key/value pairs matching the given keys.
739740
#

actionpack/test/controller/parameters/accessors_test.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,17 @@ class ParametersAccessorsTest < ActiveSupport::TestCase
149149
assert_not_predicate @params[:person].except(:name), :permitted?
150150
end
151151

152+
test "without retains permitted status" do
153+
@params.permit!
154+
assert_predicate @params.without(:person), :permitted?
155+
assert_predicate @params[:person].without(:name), :permitted?
156+
end
157+
158+
test "without retains unpermitted status" do
159+
assert_not_predicate @params.without(:person), :permitted?
160+
assert_not_predicate @params[:person].without(:name), :permitted?
161+
end
162+
152163
test "exclude? returns true if the given key is not present in the params" do
153164
assert @params.exclude?(:address)
154165
end

0 commit comments

Comments
 (0)