Skip to content
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

Feature Request: Error if content_for called from within fragment cache #28072

Closed
mipearson opened this issue Feb 19, 2017 · 3 comments
Closed

Comments

@mipearson
Copy link
Contributor

mipearson commented Feb 19, 2017

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_inlcude_tag ... %>
<% 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.

System configuration

Rails 5.0.1, Ruby 2.3.1

@st0012
Copy link
Contributor

st0012 commented Feb 23, 2017

I think feature request should be posted in mailing list?

@maclover7
Copy link
Contributor

Agree with @st0012. Please use the mailing list for feature requests, where a wider community will be able to help you. We reserve the issues tracker for issues only.

@mipearson
Copy link
Contributor Author

No problem, will do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants