Module: Catche::ViewHelpers
- Defined in:
- lib/catche/view_helpers.rb
Instance Method Summary collapse
-
#catche(model_or_resource, options = {}, &block) ⇒ Object
(also: #catches_fragment)
Caches a fragment See ActionView ‘cache` for more information.
Instance Method Details
#catche(model_or_resource, options = {}, &block) ⇒ Object Also known as: catches_fragment
Caches a fragment See ActionView ‘cache` for more information
<% catche @project do %>
<%= @project.title %>
<% end %>
<% catche @projects, :model => Project do %>
<% @projects.each do |project| %>
<%= project.title %>
<% end %>
<% end %>
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/catche/view_helpers.rb', line 16 def catche(model_or_resource, ={}, &block) = [] name = Catche::Tag.join 'fragment', model_or_resource.hash key = ActiveSupport::Cache. name, :views object = [:model] || model_or_resource if object.respond_to?(:catche_tag) if object.respond_to?(:new) = Catche::Tag::Collect.collection(controller, object)[:set] else = Catche::Tag::Collect.resource(object)[:set] end end Catche::Tag.tag_view! key, * if .any? cache name, , &block end |