Fix digesting templates with mixed formats #32282
Conversation
I've tested this against the repro I created when I reported #28503 and this PR resolves the issue. I've been unable to immediately test this against the production app where I first noticed this issue as the app doesn't play nice with rails master presently. Hopefully this can be backported against 5.1 and 5.2 - which I'm happy to help with. |
Having now backported the fix to 5.1 stable I can confirm that this fixes the issue I was experiencing. |
Nice! Feel free to backport to 5-2-stable and 5-1-stable. |
I think I've found a better solution that aligns more closely with the behavior of rendering: 052a6d5 By setting rails/actionview/lib/action_view/lookup_context.rb Lines 245 to 255 in d9736e5 Rendering a request works similarly: rails/actionview/lib/action_view/rendering.rb Lines 106 to 111 in d9736e5 @thomasfedb, mind trying once more with my latest commit? If it doesn't pan out I'll use my first approach. @kaspth, if you have any other ideas, please do let me know! It's a jungle in there. |
@javan would that break if I, for example, tried to render a |
I think that will work, but please do investigate. |
@javan I'll give it a try |
@javan new fix definitely solves the issue when using HTML partials inside JS views as with the previous fix. There is an issue, however, when you render a partial with a particular format, e.g. |
The above happens inside both JS and HTML views, as you'd expect. |
Sorry, should make it clear that this issue with rendering with specified format appears only to occur with the new fix, and was not a problem with the initial fix. With initial fix:
With new fix:
Let me know if you need further info @javan |
Thanks @thomasfedb! It looks like |
@javan right, there was only |
Went with the 2nd approach. Thanks for all your help @thomasfedb! |
Fix digesting templates with mixed formats
Fix digesting templates with mixed formats
Thanks @javan, and clue as to when the next 5.1.x will be cut? |
I'm not sure about the 5-1 release schedule. Maybe @rafaelfranca knows? You can always point your Gemfile at the Rails branch or sha. |
Using the branch now in dev, but would prefer to have an official release before I deploy to prod. |
It may takes months. We usually release every 6 weeks, but given 5.2 is going to be the official release, it may take more time. |
@javan This PR broke a project I'm working on because I had a similar case to your example ("more than one |
@erikthiem I think you'd need to make |
I think that this may have been solved by. rails/rails#28503 rails/rails#32282
I think that this may have been solved by. rails/rails#28503 rails/rails#32282
Fixes #28503
Follow up to: #25411