Render partial from cache substantially faster.

Updated . Posted . Visible to the public.

For example we have a view and a partial view named index.html.erb and _todo.html.erb.

/app/views/todos/index.html.erb

<%= render partial: 'todo', collection: @todos, cached: true %>

When cached: true present, Rails will use read_multi to the cache store instead of reading from it every partial.

_/app/views/todos/todo.html.erb

<% cache todo do %>
  <%= todo.name %>
<% end %>
Alexander M
Last edit
Alexander M
Tags
Posted by Alexander M to Ruby and RoR knowledge base (2016-04-02 20:06)