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
Read fragment views/tests/index:06ce85b70ee7a70c70923bcbbff4dc2d/1693531182 (0.1ms)
Write fragment views/tests/index:06ce85b70ee7a70c70923bcbbff4dc2d/1693531182 (0.1ms)
Actual behavior
Couldn't find template for digesting: news/new
Read fragment views/tests/index:06ce85b70ee7a70c70923bcbbff4dc2d/1693531182 (0.1ms)
Write fragment views/tests/index:06ce85b70ee7a70c70923bcbbff4dc2d/1693531182 (0.1ms)
<%= cache Time.current.to_i do %><%= render TestComponent.new %><% end %>
Refresh the page and check the logs
Modify the template
<%= cache Time.current.to_i do %>
something new
<%= render TestComponent.new %><% end %>
Refresh the page and check the logs
The text was updated successfully, but these errors were encountered:
davidalejandroaguilar
changed the title
Fragment caching an erb template with a Phlex component is not working
Fragment caching an erb template with a Phlex component complains it can't digest template
Sep 1, 2023
@davidalejandroaguilar I’ve looked into this and confirmed the problem. It looks like Rails builds up a dependency tree by parsing the ERB files and finding render calls. It only does this when rendering partials.
For Phlex to fit in here, Rails would have to parse render calls to objects, e.g. render Foo.new and then establish an interface that the class can implement to be a part of the dependency tree.
We would be happy to implement a class method on our renderable classes if that was supported by Rails.
I think the best way forward is to bring this up in a new Rails issue. You can mention this issue and this one from ViewComponent. ViewComponent/view_component#234
For now, I’m going to close this as there’s nothing we can do here until something changes in Rails.
Expected Behavior
Actual behavior
How to reproduce
Refresh the page and check the logs
Modify the template
The text was updated successfully, but these errors were encountered: