Repository navigation
Accept strong parameters in the node builders; follow-ups to #1804 - #1805
Merged
Merged
Conversation
`Search#initialize` unwraps `ActionController::Parameters`, but the nodes built afterwards went through `Node#indifferent_params`, which only took objects responding to `with_indifferent_access`. `build_grouping` and `build_sort` given strong parameters raised `InvalidSearchError`. They are now unwrapped there too. Whether the search counts as permitted is still decided only by the params it was created from. The callers now pass the article, as `scalar_param`'s do, so the message reads "supplied for an attribute" rather than "a attribute". Also drops the blank line left before the end of the class. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
RuboCop runs with every cop disabled by default and none of the enabled ones checked that `end` lines up with its `def`, which is how the misindented methods in Ransack::Nodes::Node got through. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The error classes live in ransack/errors, which `require 'ransack'` loads. Code that requires `ransack/invalid_search_error` directly needs to require `ransack` or `ransack/errors` instead. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
scarroll32
force-pushed
the
strong-params-in-builders
branch
from
November 16, 2026 14:57
65a6e32 to
472d4cc
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this changes
Follow-ups found while reviewing #1804. This branch is stacked on that PR's commit, because every change here touches the lines it re-indents, so #1804 should merge first; until it does, its whitespace fix shows up in this diff too.
Strong parameters are accepted by the builders.
Search#initializeunwrapsActionController::Parameters, but nodes built afterwards go throughNode#indifferent_params, which only took objects responding towith_indifferent_access:Both now build the grouping or sort. Before #1763 the same calls raised
NoMethodError, so this was never a regression. The unwrap does not widen authorization: a model's allowlist still applies, and whether a search of a model with no allowlist counts as permitted is still decided only by the params the search was created from. Both are covered by specs.Error message grammar.
indifferent_paramsbuilt its message assupplied for a #{node_name}, which gavesupplied for a attribute. Callers now pass the article, asscalar_param's already do. The other messages are unchanged.Layout/DefEndAlignmentis enabled. RuboCop runs withDisabledByDefault: trueand nothing checked thatendlines up with itsdef, so the misindentation #1804 fixes passed CI. This cop flags it onmainand has no other offenses inliborspec.The blank line before the end of
Ransack::Nodes::Nodeis removed.lib/ransack/invalid_search_error.rbis removed. It was a one-line shim that requiredransack/errors, where the error classes live.Backward compatibility
Removing the shim breaks
require 'ransack/invalid_search_error', which has worked since 4.3.0. Code that requires that file directly needsrequire 'ransack'orrequire 'ransack/errors'instead.Ransack::InvalidSearchErroritself is unchanged. There is no entry for this in the upgrading guide yet, because it has no section for the next release.Not changed
The setters (
sorts=,groupings=,conditions=,attributes=,values=) still take only anArrayorHash, so strong parameters assigned to them directly are not unwrapped.Checklist
bundle exec rake specpassesdocs/are updated for any user-visible changeThe five new strong-parameter examples and the new message assertion fail without the
libchange. Full suite: 1174 examples, 0 failures on SQLite with Active Record 8.1.4.1; PostgreSQL and MySQL were not run locally.🤖 Generated with Claude Code