Skip to content

Instantly share code, notes, and snippets.

@jrallison
Created January 20, 2011 19:22
Show Gist options
  • Save jrallison/788437 to your computer and use it in GitHub Desktop.
Save jrallison/788437 to your computer and use it in GitHub Desktop.
Easily mix dynamic content with fragment caching
<% @somethings.each do |something| %>
<%= cache("somethings:#{something.id}", :time => something.created_at) do %>
<div class="something">
<%= render "somethings/expensive_calculation" %>
<!-- time.strftime(...) calculated dynamically every time -->
<p class="timestamp"><%= time.strftime("%B %d, %Y") %></p>
</div>
<% end %>
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment