Sto seguendo un libro chiamato Sviluppo Web agile con Rails 4 e sto riscontrando un problema mentre capisco cosa fa cache ['store', Product.latest]
nel file di visualizzazione.Rails: cosa fa la funzione cache ['store', Product.latest] nella cache dei frammenti?
#static function latest is defined in the model
def self.latest
Product.order(:updated_at).last
end
#here is my view file
<% cache['store',Product.latest] do %>
<% @products.each do|product| %>
<% cache['entry',product] do %>
<div class="entry">
<%= image_tag(product.image_url) %>
<h3><%= product.title %></h3>
<%= sanitize(product.description) %>
<div class="price_line">
<span class="price"><%= number_to_currency(product.price) %></span>
</div>
</div>
<% end %>
<% end %>
<% end %>
Hai [leggi questo] (http://edgeguides.rubyonrails.org/caching_with_rails.html)? – GoBusto