Analysis: Improve how render calls resolve to partials - #2229
Open
marcoroth wants to merge 27 commits into
Open
Conversation
|
View your CI Pipeline Execution ↗ for commit 07e02b9
💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗ ☁️ Nx Cloud last updated this comment at |
marcoroth
force-pushed
the
partial-index-discovery
branch
from
August 14, 2026 04:57
67ca7d1 to
3cc85b3
Compare
marcoroth
force-pushed
the
partial-index-discovery
branch
from
August 14, 2026 06:02
6433449 to
2845ba4
Compare
🌿 Interactive Playground and Documentation PreviewA preview deployment has been built for this pull request. Try out the changes live in the interactive playground: 🌱 Grown from commit |
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.
This pull request teaches the partial index about Rails'
view_pathsinstead of a single guessed root, and stops discarding templates that Rails will render but the globs do not match.Running
herb actionview checkagainst a large application reported 118 unresolved render calls. Most of them pointed at partials that exist on disk. Two causes, both ours.The first is a template that carries a handler but no format. Rails reads a filename as
name.format.handler, and the format segment is optional, so_icon.erbis a real partial that Rails serves for any format.PartialResolution::EXTENSIONSalready agrees, and the filesystem walk already finds it.PartialIndex#build_with_configthen replaced that walk with the linter's file list, whose globs enumerate HTML formats (**/*.html.erb,**/*.html,**/*.rhtml), and every such partial vanished from the index.The config's globs still decide what the linter and formatter look at. The index just keeps what the walk found.
The second is that a Rails application has an ordered list of view paths, not one. The application comes first, then each engine, then anything pushed on at runtime, and a name resolves against each in turn. The index held a single
view_rootand derived every partial name relative to it, so a template under an engine could not be named at all and was silently skipped.PartialIndexnow takes the list, in precedence order:The shared primitive reports which root matched, so position can order two partials that share a name. An earlier view path shadows a later one, which extension precedence alone could not express, and a sibling render resolves within the root that owns the calling template.
checkgained a section for templates whose filename omits the format, since these resolve in Rails but are easy to write by accident:Both entry points and partials appear, because a formatless mailer view is a template in both directions: we were failing to resolve into these files and failing to walk out of them.
render "layouts/page.html.erb"names a partial that exists, but the extension is part of the name, so appending another one never matched. The file was reported as unresolved at the call site and as unused at the same time. Resolution now strips a known template extension from the name first.