Skip to content

Commit 2c46fc9

Browse files
flavorjonesclaude
andcommitted
Minor improvements to reactions code
- Use size instead of count in boosts partial to avoid extra SQL query on already-loaded collection - Add else clause to reaction_path_prefix_for to raise ArgumentError for unknown reactable types instead of silently returning nil Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 1d21417 commit 2c46fc9

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

app/helpers/reactions_helper.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ def reaction_path_prefix_for(reactable)
33
case reactable
44
when Card then [ reactable ]
55
when Comment then [ reactable.card, reactable ]
6+
else
7+
raise ArgumentError, "Unknown reactable type: #{reactable.class}"
68
end
79
end
810
end

app/views/cards/display/preview/_boosts.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
<% if boosts.any? %>
33
<div class="card__boosts">
44
<%= image_tag "boost-color.svg", aria: { hidden: true } %>
5-
<span><%= boosts.count %></span>
5+
<span><%= boosts.size %></span>
66
</div>
77
<% end %>

0 commit comments

Comments
 (0)