Repository navigation
Match GET case-insensitively when deciding an action is a link - #38
Merged
Merged
Conversation
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.
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.
A custom action declared with
http_methods [:GET]routed and authorized fine butnever 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 unreachablefrom the UI, which is the part that makes it expensive to notice.
http_methodsis 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. Onlythe 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: itis the common case and
menu_foris on a hot path.Unapplied review findings
lib/rails_admin_next/config/actions/base.rb—linkable?is aplain method, not a
register_instance_option, so a host cannot override "isthis action a link" independently of
http_methods. Matches the pre-existinginline checks, so not a regression, but there is no hook for a host that wants
a GET action rendered as a button.
http_methodsbeing empty or carrying a nil entry.Unexercised before this change too.
Closes #31