Extract helper method to keep partial at a uniform level of abstraction

This commit is contained in:
David Heinemeier Hansson
2025-04-17 15:42:07 +02:00
parent 63b2abe020
commit 461c104ac2
2 changed files with 9 additions and 4 deletions
+8
View File
@@ -29,4 +29,12 @@ module CardsHelper
**options,
&block
end
def button_to_delete_card(card)
button_to collection_card_path(card.collection, card),
method: :delete, class: "btn", data: { turbo_confirm: "Are you sure you want to delete this?" } do
concat(icon_tag("trash"))
concat(tag.span("Delete", class: "for-screen-reader"))
end
end
end
+1 -4
View File
@@ -6,10 +6,7 @@
<%= render "cards/container/gild", card: card if card.doing? %>
<%= render "cards/container/image", card: card %>
<%= button_to collection_card_path(card.collection, card),
method: :delete, class: "btn", data: { turbo_confirm: "Are you sure you want to delete this?" } do %>
<%= icon_tag "trash" %> <span class="for-screen-reader">Delete</span>
<% end %>
<%= button_to_delete_card(card) %>
</aside>
<div class="card-perma__bg">