Posted over 5 years ago. Visible to the public.

Render partial from cache substantially faster.

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

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

Copy
<%= 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

Copy
<% cache todo do %> <%= todo.name %> <% end %>

Owner of this card:

Avatar
Alexander M
Last edit:
over 5 years ago
by Alexander M
Tags:
Rails-5-0
Posted by Alexander M to Ruby and RoR knowledge base
This website uses short-lived cookies to improve usability.
Accept or learn more