Skip to content

Document behaviour shipping in 4.5.0 - #1695

Merged
scarroll32 merged 1 commit into
mainfrom
docs-4-5-0
Sep 21, 2026
Merged

scarroll32 merged 1 commit into
mainfrom
docs-4-5-0

Conversation

@scarroll32

Copy link
Copy Markdown
Member

Note

This PR was opened by Claude (Claude Code), acting on behalf of @scarroll32.

Three changes already merged for 4.5.0 shipped without documentation.

enum support (#1665)

Entirely undocumented — nothing in docs/ mentioned enums at all, so there was no way to know Ransack handles them short of reading the specs. Adds a section to Search Matchers showing that an enum can be searched by label rather than underlying value:

Person.ransack(temperament_eq: 'choleric').result.to_sql
# ... WHERE "people"."temperament" = 2

Person.ransack(temperament_in: ['sanguine', 'choleric']).result.to_sql
# ... WHERE "people"."temperament" IN (1, 2)

which is what makes a select built from Person.temperaments.keys post back cleanly.

Per-search search_key (#1676)

The Configuration page still told readers to write <%= f.search_form_for @search, as: :log_search %> — that as: was the workaround for the bug #1676 fixed. Updated to show the helpers reading the key from the search object, with a note that passing it explicitly still works and still wins.

(The old snippet also had a bug of its own: f.search_form_for rather than search_form_for.)

Symbol allowlists (#1539)

Records that ransackable_attributes and ransackable_associations accept symbols or strings interchangeably — and that before 5.0 a symbol list matched nothing, so searches were silently ignored. That's worth stating explicitly, since the failure mode gave no error.

Verification

Every example was run against the spec schema rather than written from memory — including rendering a real search_form_for through a controller view context to confirm the field names come out as person_search[name_cont].

Note on #1657

While checking examples for this, I found that #1657 (Allow nil values in array) doesn't do what its title suggests for built-in predicates:

Person.ransack(name_in: [nil]).result.to_sql
# => SELECT "people".* FROM "people"        ← no WHERE at all

Person.ransack(name_in: [nil, 'Ernie']).result.to_sql
# => ... WHERE "people"."name" IN ('Ernie') ← nil dropped

The change keeps the parameter alive through Search#initialize, but the built-in in predicate's validator still rejects nil afterwards. It only helps a custom predicate with a permissive validator — which was the author's actual use case in #940. So it's not wrong, just narrower than the title reads, and I've deliberately not documented it as a user-facing feature. Worth wording carefully in the release notes.

🤖 Generated with Claude Code

Three changes merged for 4.5.0 had no documentation:

enum (#1665) was entirely undocumented. Adds a section showing that an
Active Record enum can be searched by label, with eq and in examples, so
a select built from Model.enums.keys can be posted back unchanged.

Per-search search_key (#1676): the configuration page still told readers
to repeat the key as `as: :log_search` in the view, which was the
workaround for the bug that PR fixed. The helpers now read it from the
search object.

Symbol allowlists (#1539): records that ransackable_attributes and
ransackable_associations accept symbols or strings interchangeably, and
that a symbol list previously matched nothing.

Each example was run against the spec schema.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@scarroll32 scarroll32 mentioned this pull request Sep 21, 2026
@scarroll32
scarroll32 merged commit 1c92b41 into main Sep 21, 2026
26 checks passed
@scarroll32
scarroll32 deleted the docs-4-5-0 branch September 21, 2026 10:56
@scarroll32 scarroll32 mentioned this pull request Sep 21, 2026
46 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant