Cached collections only work if there is one template #35253
Merged
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.
I don't know this is the right fix necessarily.
When rendering a collection, each object in the collection can respond to
to_partial_path
. The template renderer will render the partial returned by that method. However, each object in the collection could return a different template. That means there isn't one template associated with the collection. Our collection template cache code depends on the collection using just one template. If you try to setcached: true
on a collection that doesn't have just one template associated with it, it will raise an exception.The patch in this PR fixes the exception, but doesn't actually cache the templates. Obviously, this use case isn't supported today, and it seems like nobody has noticed.