Repository navigation
Let an app move the notice flash key once - #7
Merged
Merged
Conversation
Fivell
force-pushed
the
notice-flash-key-default
branch
2 times, most recently
from
October 19, 2026 17:17
db0f983 to
0cc8e39
Compare
There was a problem hiding this comment.
🟡 Changes recommended
The resource-precedence test uses identical keys and cannot detect a broken override.
1 open issue
What changed in this PR
Adds an application-wide flash key for default-filter notices while preserving resource-specific overrides and the existing :notice default.
Changes:
- Resolves notice keys at write time through a shared helper.
- Documents configuration and adds integration coverage.
- Bumps the version to 1.1.0.
| File | Description |
|---|---|
| spec/integration/filter_defaults_spec.rb | Tests global configuration and resource precedence. |
| README.md | Documents application-wide configuration. |
| lib/active_admin_filter_extensions/version.rb | Bumps version to 1.1.0. |
| lib/active_admin_filter_extensions/redirect.rb | Uses shared key resolution for redirects. |
| lib/active_admin_filter_extensions/notice.rb | Resolves resource and application keys at write time. |
| lib/active_admin_filter_extensions.rb | Adds the application-wide setting. |
Review effort: Balanced
`flash_key:` was per resource, so an application that renders its own flash key for "why this page is cut down" had to repeat it on every index declaring a notice - or reach for a prepend on ResourceDSL to move the default. `ActiveAdminFilterExtensions.notice_flash_key` is that default. It is read when the notice is written rather than when the resource is registered, so initializer order does not decide it and a test can move it around one request. What the resource declared still wins.
Fivell
force-pushed
the
notice-flash-key-default
branch
from
October 19, 2026 17:30
0cc8e39 to
efa55ef
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.

Why
default_filters_noticetakesflash_key:per resource, defaulting to:notice. An application that renders its own flash key for "why this page is cut down" therefore repeats it on every index that declares a notice — or reaches for aprependonActiveAdmin::ResourceDSLto move the default, which is monkeypatching the DSL to change one default value. Nothing in the gem offered a place to say it once.The key is not cosmetic. Active Admin writes action results to
:notice, andRedirectresolves a collision in favour of the arriving message (redirect.rb:69-76), so on a shared key an action's result silences the filters notice. That matters for an index that both declares default filters and is where create/update/batch actions land — the admin learns why the page is cut down only on visits where they did nothing. An application like that needs a key of its own, and should be able to choose it once.What
:notice— nothing changes for an application that says nothing.Notice.flash_key_for), so initializer order cannot decide it and both writers — thebefore_actionand the redirect's travelling flash — go through one method.flash_key:on the resource still wins.Tests
spec/integration/filter_defaults_spec.rb, underdefault_filters_notice: one example moves the app-wide key around a single request and asserts the rendered flash class (.flash_filters_noticepresent,.flash_noticeabsent); the other checks that a resource which declared its own key keeps it.The first example discriminates the design, not just the accessor: had the key been captured at registration, moving it after boot would leave the notice on
:noticeand the assertion would fail.Full suite: 198 examples, 0 failures. Version bumped to 1.1.0.