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
Fix missing partial iteration #27795
Fix missing partial iteration #27795
Conversation
Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @chancancode (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. This repository is being automatically checked for code quality issues using Code Climate. You can see results for this analysis in the PR status below. Newly introduced issues should be fixed before a Pull Request is considered ready to review. Please see the contribution instructions for more information. |
Thanks for working on this! Can you add a test so we don't have a regression in the future? |
And this branch should be pointing at master, unless this is not broken on master? |
@eileencodes Sure, tests incoming, familiarizing myself with the test suite. Is the convention to fix these bugs on |
No worries! The convention is to fix on master and merge to the appropriate branches. I tried changing the base for you but there's just too much that's different between master and 5-0-stable that it would be better to open a new PR pointing to master. |
03ce5b5
to
32f92cf
Compare
Fixed to merge into |
When rendering heterogeneous collection using `render @collection` or `render partial: @collection`, the expected `<partial_name>_iteration` variable is missing due to `find_template` not having the name of the iteration variable included in its cache keys.
32f92cf
to
e524327
Compare
I added a test, which necessitated adding two new fixture partials. I tried re-using the existing
There is potentially a lower-level issue with ERB templates that my pull request doesn't address. A template gets a list of local names when built (as an array of strings) and then later when executed it gets a See https://github.com/rails/rails/blob/master/actionview/lib/action_view/template.rb#L325 Only the variables previously set in I'm not sure if this is intentional behavior, but my fix is to simply create the template with the correct list of local names. |
Not sure how to move forward with regards to the failing test in TravisCI. The test is passing for me locally, and I can't imagine how my changes could have induced a failure. |
@eileencodes Not sure if there's something I should be doing to bump this along? |
hey @meagar - sometimes tests fail randomly that have nothing to do with your branch so don't worry about that if it's not failing for you. When we get around to reviewing your PR and merging we will. Hang tight. 🙂 |
Fix missing partial iteration
Backported in 24c585d. Thanks! |
Summary
Fixes #27794
The iteration variable was being assigned to the correct key in the
locals
hash, but the name of the iteration variable (<partial_name>_iteration
) was not included in the keys tofind_template
, meaning it was excluded fromkeys
, a partial to be loaded without the<partial_name>_iteration
variable defined as one of it's locals during initialization.Other Information
I produced a simple POC against Rails 5.0.1, and created screenshots of the actual and expected behavior.