Skip to content

Commit 5d6db6a

Browse files
committed
simpler cache key
1 parent f892c85 commit 5d6db6a

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

app/models/watched_talk.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@
1515
# index_watched_talks_on_user_id (user_id)
1616
#
1717
class WatchedTalk < ApplicationRecord
18-
belongs_to :user, default: -> { Current.user }
18+
belongs_to :user, default: -> { Current.user }, touch: true
1919
belongs_to :talk
2020
end

app/views/talks/show.html.erb

+1-7
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,8 @@
1313
<% end %>
1414
</div>
1515

16-
<% if signed_in? %>
17-
<% cache_key = [@talk, Current.user, @talk.watched_talks.where(user: Current.user)] %>
18-
<% else %>
19-
<% cache_key = [@talk] %>
20-
<% end %>
21-
2216
<%= turbo_frame_tag "talk", target: "_top", data: {turbo_action: "advance"} do %>
23-
<% cache cache_key do %>
17+
<% cache [@talk, Current.user].compact do %>
2418
<%= render partial: "talks/talk", locals: {talk: @talk} %>
2519
<% end %>
2620
<% end %>

0 commit comments

Comments
 (0)