Skip to content

Commit 84eb5fe

Browse files
committed
[Doc] Update the doc for Rails/StrongParametersExpect
Closes #1637.
1 parent 5490e3e commit 84eb5fe

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

‎lib/rubocop/cop/rails/strong_parameters_expect.rb‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ module Rails
2929
# from an array of nested hashes, so it always generates the single-hash form, which can turn
3030
# a previously successful request into a failure.
3131
#
32+
# It is also unsafe when `params[:key]` is passed to a finder method such as `find`, because
33+
# `find` accepts an array of IDs. `Model.find(params[:id])` loads every record for an array of IDs,
34+
# but the corrected `Model.find(params.expect(:id))` raises `ActionController::ParameterMissing`
35+
# for an array value, since `expect` requires a scalar. The cop cannot tell a scalar ID from
36+
# an array of IDs, so the autocorrection can turn a previously successful request into a failure.
37+
#
3238
# @example
3339
#
3440
# # bad

0 commit comments

Comments
 (0)