New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use the lookup_context to find the correct template path #42437
Use the lookup_context to find the correct template path #42437
Conversation
9d2f41a
to
3044fd7
Compare
This replaces the controller/action method of finding a path with the lookup_context which should always find the same thing as the render method finds.
3044fd7
to
26259b0
Compare
@@ -44,7 +44,7 @@ def determine_template_etag(options) | |||
# template digest from the ETag. | |||
def pick_template_for_etag(options) | |||
unless options[:template] == false | |||
options[:template] || "#{controller_path}/#{action_name}" | |||
options[:template] || lookup_context.find_all(action_name, _prefixes).first&.virtual_path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not lookup_context.find(action_name, _prefixes).virtual_path
? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
find
will raise an error if it doesn't find the template. I don't think we want to raise here since we didn't raise before. It fails a lot of actionpack tests that don't have templates but ask about the etag
.
Maybe it would be worth switching to find
? should we raise if it can't find the template you want as part of your etag? That would be new behavior, but might help people find problems with their cache keys? I am unsure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@HParker I would avoid trying to solve problems people aren't experiencing, this PR already adds enough value IMO ❤️
…template Use the lookup_context to find the correct template path
This replaces the controller/action method of finding a path with the lookup_context which should always find the same thing as the render method finds.
Closes: #42417