You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A select submits a marker (__none__ or __present__) under its own key. Only the search sees it, as _null or _not_null. Defaults, required:, the policies and the redirect read the request as submitted. Each marker option carries filter-extensions-option filter-extensions-none|present and data-filter-extensions-option, plus any class: given, for styling a plain select or a Tom Select.
Decisions a reviewer can't see in the diff:
None beside other values is a Ransack OR grouping. Present beside values searches _not_null only. None plus Present searches no condition.
String and numeric filters get the choices in Active Admin's predicate dropdown (_blank/_present, _null/_not_null). Active Admin submits no empty box, so the gem now ships a small script that fills the box with 1 and hides it. Apps add it with //= require active_admin_filter_extensions on Active Admin 3. On Active Admin 4 it is pinned into ActiveAdmin.importmap.
Other filters with none: or present: raise ArgumentError.
Current Filters reads "Account equals None" and "Account equals Present".
Verified: the suite passes on Active Admin 3.5 and 4.0.0.beta23 (31 unit and 246 integration examples each).
extensions: { none: true } adds a None choice that searches the attribute's _null. Only the search sees the rewrite, so defaults, policies and the redirect still read the request as submitted.
Co-Authored-By: Clanker
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Restoring false-valued predicates overwrites their answers with 1 in both Ruby and JavaScript, so resubmitting the form can silently reverse the search.
Adds None and Present choices to the gem’s Active Admin filters, integrating empty/set searches with existing defaults, policies, and Current Filters labels.
Changes:
Adds select markers and string/numeric predicates, with configurable labels and styling hooks.
Adds JavaScript and asset integration to submit predicates that require no typed value.
Documents setup and adds unit, integration, and browser coverage.
File
Description
spec/support/rails_template.rb
Adds filter fixtures, nullable associations, and script loading.
spec/spec_helper.rb
Loads marker support into unit-test helpers.
spec/marker_options_spec.rb
Tests public marker rewriting behavior.
spec/integration/present_option_spec.rb
Covers Present selections, policies, and labels.
spec/integration/predicate_option_spec.rb
Covers predicate dropdowns and browser submission.
spec/integration/none_option_spec.rb
Covers None selections, defaults, and grouped searches.
README.md
Documents options, script setup, styling, and dependent selects.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Default None/Present predicates still undergo attribute value validation, causing valid defaults to raise ArgumentError on a bare visit even though equivalent submitted predicates bypass validation.
No open issues 🎉
1 previously missed issue
In code that hasn't changed since last review
Skip None/Present predicates during default sanitization and validation
A None/Present predicate used as a default still reaches the attribute's value policies because this exemption only recognizes select markers. For example, filter :title, extensions: { none: true, default: { blank: "1" }, validate: ->(v) { "Too short" if v.size < 3 } } raises ArgumentError on a bare visit when the validator receives "1", although submitting title_blank=1 bypasses it. Skip declared None/Present predicate keys before default sanitization and validation too.
A submitted title_blank=1 is not handed to validate: or sanitize:, but
the same predicate as a default was, and a strict validator raised at
boot. Specs and a README table now show which of "john", "", " " and
NULL None and Present return on a select and in the dropdown.
Co-Authored-By: Clanker
The Copilot finding from the latest review is fixed in 0e250af: a default None or Present predicate went through sanitize: and validate:. Defaults now skip the same boolean predicates that a submitted request skips, unless the filter derives that key itself. So default: { blank: "1" } with a strict validate: no longer raises. A new spec fails without the fix. The same rule also covers older defaults such as default: { null: true }, which failed the same way before this PR.
Both suites pass on Active Admin 3.5 and 4.0.0.beta23: 31 unit and 246 integration examples each.
Minor: #9 adds Active Admin 4 support and keeps Active Admin 3
unchanged, apart from hiding the empty Current Filters panel after a
blank submit. #11 adds opt-in None and Present options. Their string
and numeric predicates need the gem's script, which Active Admin 3
apps add with `//= require active_admin_filter_extensions`.
Co-Authored-By: Clanker
Minor: #9 adds Active Admin 4 support and keeps Active Admin 3
unchanged, apart from hiding the empty Current Filters panel after a
blank submit. #11 adds opt-in None and Present options. Their string
and numeric predicates need the gem's script, which Active Admin 3
apps add with `//= require active_admin_filter_extensions`.
Co-Authored-By: Clanker
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
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.
Adds "None" and "Present" choices to filters, for records whose attribute is empty or set:
A select submits a marker (
__none__or__present__) under its own key. Only the search sees it, as_nullor_not_null. Defaults,required:, the policies and the redirect read the request as submitted. Each marker option carriesfilter-extensions-option filter-extensions-none|presentanddata-filter-extensions-option, plus anyclass:given, for styling a plain select or a Tom Select.Decisions a reviewer can't see in the diff:
_not_nullonly. None plus Present searches no condition._blank/_present,_null/_not_null). Active Admin submits no empty box, so the gem now ships a small script that fills the box with1and hides it. Apps add it with//= require active_admin_filter_extensionson Active Admin 3. On Active Admin 4 it is pinned intoActiveAdmin.importmap.none:orpresent:raiseArgumentError.Verified: the suite passes on Active Admin 3.5 and 4.0.0.beta23 (31 unit and 246 integration examples each).