Skip to content

Commit

Permalink
cache speakers index
Browse files Browse the repository at this point in the history
  • Loading branch information
adrienpoly committed Sep 16, 2024
1 parent ad99029 commit 4cfa5d4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/controllers/speakers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class SpeakersController < ApplicationController
def index
respond_to do |format|
format.html do
@speakers = Speaker.with_talks.order(:name).select(:id, :name, :slug, :talks_count, :github)
@speakers = Speaker.with_talks.order(:name).select(:id, :name, :slug, :talks_count, :github, :updated_at)
@speakers = @speakers.where("lower(name) LIKE ?", "#{params[:letter].downcase}%") if params[:letter].present?
end
format.json do
Expand Down
4 changes: 3 additions & 1 deletion app/views/speakers/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
<% end %>
</div>
<div id="speakers" class="grid sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-x-8 lg:gap-x-12 gap-y-2 min-w-full">
<%= render @speakers %>
<% cache @speakers do %>
<%= render partial: "speakers/speaker", collection: @speakers, as: :speaker, cached: true %>
<% end %>
</div>
</div>

0 comments on commit 4cfa5d4

Please sign in to comment.