aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/lib/action_view/renderer/partial_renderer.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2019-02-13 08:49:05 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2019-02-13 10:35:28 -0800
commitbfcdd46614407d6bf1c955aad6ed4aa3094d2189 (patch)
treec51e9c35dd81749f674f69623187cbe1ae096b84 /actionview/lib/action_view/renderer/partial_renderer.rb
parent38f9e41f2c4b64377ffb036c53873dbfb51546cf (diff)
downloadrails-bfcdd46614407d6bf1c955aad6ed4aa3094d2189.tar.gz
rails-bfcdd46614407d6bf1c955aad6ed4aa3094d2189.tar.bz2
rails-bfcdd46614407d6bf1c955aad6ed4aa3094d2189.zip
Cached collections only work if there is one template
Cached collections only work if there is one template. If there are more than one templates, the caching mechanism doesn't have a key.
Diffstat (limited to 'actionview/lib/action_view/renderer/partial_renderer.rb')
-rw-r--r--actionview/lib/action_view/renderer/partial_renderer.rb14
1 files changed, 11 insertions, 3 deletions
diff --git a/actionview/lib/action_view/renderer/partial_renderer.rb b/actionview/lib/action_view/renderer/partial_renderer.rb
index 801916954f..75bca3d0c4 100644
--- a/actionview/lib/action_view/renderer/partial_renderer.rb
+++ b/actionview/lib/action_view/renderer/partial_renderer.rb
@@ -308,6 +308,9 @@ module ActionView
template = find_partial(@path, @template_keys)
@variable ||= template.variable
else
+ if options[:cached]
+ raise NotImplementedError, "render caching requires a template. Please specify a partial when rendering"
+ end
template = nil
end
@@ -337,9 +340,14 @@ module ActionView
spacer = find_template(@options[:spacer_template], @locals.keys).render(view, @locals)
end
- cache_collection_render(payload, view, template) do
- template ? collection_with_template(view, template) : collection_without_template(view)
- end.join(spacer).html_safe
+ collection_body = if template
+ cache_collection_render(payload, view, template) do
+ collection_with_template(view, template)
+ end
+ else
+ collection_without_template(view)
+ end
+ collection_body.join(spacer).html_safe
end
end