From 11644fd0ceb99f3f0529323df5ad625c596b3f21 Mon Sep 17 00:00:00 2001 From: Kasper Timm Hansen Date: Sun, 15 Feb 2015 22:39:04 +0100 Subject: Collections automatically cache and fetch partials. Collections can take advantage of `multi_read` if they render one template and their partials begin with a cache call. The cache call must correspond to either what the collections elements are rendered as, or match the inferred name of the partial. So with a notifications/_notification.html.erb template like: ```ruby <% cache notification %> <%# ... %> <% end %> ``` A collection would be able to use `multi_read` if rendered like: ```ruby <%= render @notifications %> <%= render partial: 'notifications/notification', collection: @notifications, as: :notification %> ``` --- actionview/test/fixtures/test/_cached_customer.erb | 3 +++ actionview/test/fixtures/test/_cached_customer_as.erb | 3 +++ 2 files changed, 6 insertions(+) create mode 100644 actionview/test/fixtures/test/_cached_customer.erb create mode 100644 actionview/test/fixtures/test/_cached_customer_as.erb (limited to 'actionview/test/fixtures') diff --git a/actionview/test/fixtures/test/_cached_customer.erb b/actionview/test/fixtures/test/_cached_customer.erb new file mode 100644 index 0000000000..52f35a3497 --- /dev/null +++ b/actionview/test/fixtures/test/_cached_customer.erb @@ -0,0 +1,3 @@ +<% cache cached_customer do %> + Hello: <%= cached_customer.name %> +<% end %> \ No newline at end of file diff --git a/actionview/test/fixtures/test/_cached_customer_as.erb b/actionview/test/fixtures/test/_cached_customer_as.erb new file mode 100644 index 0000000000..fca8d19e34 --- /dev/null +++ b/actionview/test/fixtures/test/_cached_customer_as.erb @@ -0,0 +1,3 @@ +<% cache buyer do %> + <%= greeting %>: <%= customer.name %> +<% end %> \ No newline at end of file -- cgit v1.2.3