Hi all,
This was originally incorrectly posted at
https://github.com/rails/rails/issues/28072 - as advised, I'm now posting
it here instead.
It is very easy to accidentally call content_for from within a block that
will be fragment cached, especially if the cached fragment calls out to a
partial. eg:
<!-- index.html.erb -->
<%= cache "fragment" do %>
<!-- ... -->
<%= render "javascript_widget" %>
<% end %>
<!-- load javascript files last -->
<%= content_for :javascript_includes %>
<!--- _javascript_widget.html.erb -->
<div class="jsPlaceholder />
<% content_for :javascript_includes do %>
<%= javascript_include_tag ... %>
<script>doTheThing('.jsPlaceholder')</script>
<% end %>
*Steps to reproduce*
Call content_for from within code that will end up in a fragment cache
*Expected behavior*An error should be raised letting the developer know
that the content_for would not occur.
*Actual behavior*
The contents of the content_for are silently discarded.
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.