Skip to content

Commit 852d0cd

Browse files
authored
Merge pull request rails#53566 from fiveNinePlusR/code-doc-fixup
Fixes broken code examples in the API docs [ci skip]
2 parents 8a7d2c1 + 30fdb1a commit 852d0cd

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

actionpack/lib/action_controller/metal/strong_parameters.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -726,19 +726,19 @@ def permit(*filters)
726726
# similar to the `.require.permit` pattern. If multiple root keys are
727727
# expected, they will all be required.
728728
#
729-
# params = ActionController::Parameters.new(name: "Martin", pies: [{ type: "dessert", flavor: "pumpkin"}])
730-
# name, pies = params.expect(:name, pies: [[:type, :flavor]])
731-
# name # => "Martin"
732-
# pies # => [#<ActionController::Parameters {"type"=>"dessert", "flavor"=>"pumpkin"} permitted: true>]
729+
# params = ActionController::Parameters.new(name: "Martin", pies: [{ type: "dessert", flavor: "pumpkin"}])
730+
# name, pies = params.expect(:name, pies: [[:type, :flavor]])
731+
# name # => "Martin"
732+
# pies # => [#<ActionController::Parameters {"type"=>"dessert", "flavor"=>"pumpkin"} permitted: true>]
733733
#
734734
# When called with a hash with multiple keys, `expect` will permit the
735735
# parameters and require the keys in the order they are given in the hash,
736736
# returning an array of the permitted parameters.
737737
#
738-
# params = ActionController::Parameters.new(subject: { name: "Martin" }, object: { pie: "pumpkin" })
739-
# subject, object = params.expect(subject: [:name], object: [:pie])
740-
# subject # => #<ActionController::Parameters {"name"=>"Martin"} permitted: true>
741-
# object # => #<ActionController::Parameters {"pie"=>"pumpkin"} permitted: true>
738+
# params = ActionController::Parameters.new(subject: { name: "Martin" }, object: { pie: "pumpkin" })
739+
# subject, object = params.expect(subject: [:name], object: [:pie])
740+
# subject # => #<ActionController::Parameters {"name"=>"Martin"} permitted: true>
741+
# object # => #<ActionController::Parameters {"pie"=>"pumpkin"} permitted: true>
742742
#
743743
# Besides being more strict about array vs hash params, `expect` uses permit
744744
# internally, so it will behave similarly.

0 commit comments

Comments
 (0)