Skip to content

Conversation

@seanpdoyle
Copy link
Contributor

Motivation / Background

Prior to this commit, the ActionController::Parameters#fetch method did not yield the key to the block when fetching an unknown key. While the ActionController::Parameters interface is Hash-like, it does not inherit from Hash directly.

Detail

The Hash#fetch method yields the key to the block, so this commit changes the ActionController::Parameters#fetch behavior to do the same.

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one change. Unrelated changes should be opened in separate PRs.
  • Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex: [Fix #issue-number]
  • Tests are added or updated if you fix a bug or add a feature.
  • CHANGELOG files are updated for the changed libraries if there is a behavior change or additional feature. Minor bug fixes and documentation changes should not be included.

Prior to this commit, the `ActionController::Parameters#fetch` method
did not yield the key to the block when fetching an unknown key. While
the `ActionController::Parameters` interface is Hash-like, it **does
not** inherit from `Hash` directly.

The `Hash#fetch` method yields the key to the block, so this commit
changes the `ActionController::Parameters#fetch` behavior to do the
same.

[Hash#fetch]: https://docs.ruby-lang.org/en/master/Hash.html#method-i-fetch
@byroot byroot merged commit 3b7cdb5 into rails:main Dec 18, 2025
4 checks passed
@seanpdoyle seanpdoyle deleted the ac-parameters-fetch-block-key branch December 18, 2025 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants