Skip to content

Match GET case-insensitively when deciding an action is a link - #38

Merged
6temes merged 1 commit into
masterfrom
fix/linkable-get-actions
Sep 15, 2026
Merged

6temes merged 1 commit into
masterfrom
fix/linkable-get-actions

Conversation

@6temes

@6temes 6temes commented Sep 15, 2026

Copy link
Copy Markdown
Owner

A custom action declared with http_methods [:GET] routed and authorized fine but
never appeared in a menu, and rendered as plain text rather than a link in
breadcrumbs. Both helper call sites tested membership exactly, and
%i[GET].include?(:get) is false. Nothing raised — the action was simply unreachable
from the UI, which is the part that makes it expensive to notice.

http_methods is host-supplied, so the casing is not this engine's to control.

Routing itself was never affected: Rails' verb matchers normalise case before
comparing against request_method, so :GET, "get" and "GET" all route. Only
the two helper checks were case-sensitive.

The question both call sites actually ask is not "does this respond to GET" but "can
this be rendered as a plain link, or does it need a button because the verb mutates",
so the predicate is named for that. include?(:get) stays as the first disjunct: it
is the common case and menu_for is on a hot path.

Unapplied review findings

  • Advisory — lib/rails_admin_next/config/actions/base.rb — linkable? is a
    plain method, not a register_instance_option, so a host cannot override "is
    this action a link" independently of http_methods. Matches the pre-existing
    inline checks, so not a regression, but there is no hook for a host that wants
    a GET action rendered as a button.
  • Advisory — no spec covers http_methods being empty or carrying a nil entry.
    Unexercised before this change too.

Closes #31

A custom action declared with `http_methods [:GET]` routed and authorized
fine but vanished from menus and rendered as plain text in breadcrumbs,
because both call sites tested `http_methods.include?(:get)` exactly.
Nothing raised, so the action was simply unreachable from the UI.

The question both call sites ask is not "does this respond to GET" but
"can this be rendered as a plain link", so name it `linkable?`. Verbs are
host-supplied, so it also tolerates a string verb.
@6temes
6temes marked this pull request as ready for review September 15, 2026 05:32
@6temes
6temes merged commit 8fb1c1a into master Sep 15, 2026
8 checks passed
@6temes
6temes deleted the fix/linkable-get-actions branch September 15, 2026 05:32
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.

Custom actions declaring http_methods [:GET] never appear in menus or breadcrumbs

1 participant