Skip to content

Conversation

seanpdoyle
Copy link
Contributor

Add support for handling attribute sanitization through Strong Parameters-compliant classes like ActionController::Parameters.

The implementation draws inspiration from built-in rails cases like ActiveModel::ForbiddenAttributesProtection.

To test this behavior, add the StrongParameters class to implement #permitted?, #permit!, and #to_hash.

@seanpdoyle seanpdoyle force-pushed the strong-parameters branch 2 times, most recently from 3eb36b1 to c0b2c93 Compare January 19, 2025 01:30
Gemfile Outdated
@@ -5,6 +5,7 @@ source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}" }

branch = ENV.fetch("BRANCH", "main")
gem "actionpack", github: "rails/rails", branch: branch
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is adds a test-only dependency so that the tests can use the real ActionController::Parameters class.

seanpdoyle and others added 2 commits September 10, 2025 21:45
Add support for handling [attribute sanitization][] through [Strong
Parameters][]-compliant classes like [ActionController::Parameters][].

The implementation draws inspiration from built-in `rails` cases like
[ActiveModel::ForbiddenAttributesProtection][].

[attribute sanitization]: https://guides.rubyonrails.org/active_model_basics.html#attribute-assignment
[Strong Parameters]: https://edgeapi.rubyonrails.org/classes/ActionController/StrongParameters.html
[ActionController::Parameters]: https://edgeapi.rubyonrails.org/classes/ActionController/Parameters.html#constant-EMPTY_HASH
[ActiveModel::ForbiddenAttributesProtection]: https://github.com/rails/rails/blob/v8.0.0.1/activemodel/lib/active_model/forbidden_attributes_protection.rb#L23-L30
@rafaelfranca rafaelfranca merged commit 6dcd314 into rails:main Sep 10, 2025
36 of 37 checks passed
@seanpdoyle seanpdoyle deleted the strong-parameters branch September 11, 2025 00:10
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