You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Background: I have partials for objects that provide their data for JSON APIs, as well as JSON+LD metadata for HTML views. In my backend, there's a place to view that metadata. The code looks like this:
#jsonld.tab-pane{role: 'tabpanel'}
%h3 JSON-LD Metadata:
%small This is used to provide rich Google search results to our library pages.
.card.bg-body-tertiary
%code.card-body
%pre= JSON.pretty_generate ActiveSupport::JSON.decode(render(partial: 'library/jsonld/book', formats: [:json], locals: {book: @book}))#jsonapi.tab-pane{role: 'tabpanel'}
%h3 Public API JSON repsonse:
.card.bg-body-tertiary
%code.card-body
%pre= JSON.pretty_generate ActiveSupport::JSON.decode(render(partial: 'library/books/book', formats: [:json], locals: {book: @book}))
This code raised an error, that the second instance of ActiveSupport::JSON.decode can't be passed nil. But strangely, if I comment out the first partial render, the second one works just fine. Flip them, and nil is still rendered for the 2nd partial. It seems like there's some sort of behind the scenes issue going on here with rendering multiple .props partials in the same view, and I just wanted to pass it on. (This code worked just fine using jbuilder templates)
Activity
jho406 commentedon Mar 1, 2026
I honestly did not expect this use case, but its something we should support. I'll take a look at this, and thank you for reporting it!
Fix: Second props partial render on same view returns nil
jho406 commentedon Mar 3, 2026
@aseroff try out this branch and see if it works out for you: #64
aseroff commentedon Mar 3, 2026
This branch does solve the issue. Thanks for taking a look and addressing the issue!
jho406 commentedon Mar 4, 2026
nice! I'll stress test it on my end and release a minor this weekend. Thanks!
jho406 commentedon Mar 7, 2026
v1.0.1 released.