diff options
| author | mo <mo.khan@gmail.com> | 2017-09-22 21:17:27 -0600 |
|---|---|---|
| committer | mo <mo.khan@gmail.com> | 2017-09-22 21:17:27 -0600 |
| commit | c303cd07b7d14c699eaa7bfbff9a888796f77cfc (patch) | |
| tree | 144d6e5c934221b0cf423eab0c5119307feed877 | |
| parent | cc3cc4199554c252ae3baa3ce5418c2ebaaf5a18 (diff) | |
cache each cake card.
| -rw-r--r-- | app/views/cakes/_cake.html.erb | 9 | ||||
| -rw-r--r-- | app/views/cakes/_index.html.erb | 12 |
2 files changed, 10 insertions, 11 deletions
diff --git a/app/views/cakes/_cake.html.erb b/app/views/cakes/_cake.html.erb new file mode 100644 index 00000000..edfd983b --- /dev/null +++ b/app/views/cakes/_cake.html.erb @@ -0,0 +1,9 @@ +<div id="cake-<%= cake.id %>" class='card' data-autoview="cake-card"> + <%= link_to cake_path(cake) do %> + <%= image_tag cake.primary_image.url_for(:thumb), alt: cake.name, class: 'card-img-top' %> + <% end %> + <div class="card-body"> + <h4 class="card-title"><%= cake.name %></h4> + <p class="card-text"><small class="text-muted"><%= local_time(cake.created_at) %></small></p> + </div> +</div> diff --git a/app/views/cakes/_index.html.erb b/app/views/cakes/_index.html.erb index 15ba7a31..687a0a7c 100644 --- a/app/views/cakes/_index.html.erb +++ b/app/views/cakes/_index.html.erb @@ -1,15 +1,5 @@ <div class="card-columns"> - <% @cakes.each do |cake| %> - <div id="cake-<%= cake.id %>" class='card' data-autoview="cake-card"> - <%= link_to cake_path(cake) do %> - <%= image_tag cake.primary_image.url_for(:thumb), alt: cake.name, class: 'card-img-top' %> - <% end %> - <div class="card-body"> - <h4 class="card-title"><%= cake.name %></h4> - <p class="card-text"><small class="text-muted"><%= local_time(cake.created_at) %></small></p> - </div> - </div> - <% end %> + <%= render partial: 'cakes/cake', collection: @cakes, cached: true %> </div> <div id='more-button-row' class="row"> <%= link_to_next_page @cakes, 'More...', params: { cache: false, sort: params[:sort], q: params[:q] }, remote: true, class: 'btn pull-right hidden', data: { disable_with: 'loading...', infinite_scroll: true } %> |
