Extract helper instead of using anemic partial

This commit is contained in:
David Heinemeier Hansson
2025-10-30 16:03:10 +01:00
parent 397b7e176f
commit dfc50faee9
4 changed files with 8 additions and 6 deletions
+6
View File
@@ -7,6 +7,12 @@ module CollectionsHelper
end
end
def link_to_edit_collection(collection)
link_to edit_collection_path(collection), class: "btn", data: { controller: "tooltip" } do
icon_tag("settings") + tag.span("Settings for #{collection.name}", class: "for-screen-reader")
end
end
def referenced_collections_from(records)
Current.user.collections.where id: records.pluck(:collection_id).uniq
end
@@ -1,4 +0,0 @@
<%= link_to edit_collection_path(collection), class: "btn", data: { controller: "tooltip" } do %>
<%= icon_tag "settings" %>
<span class="for-screen-reader">Settings for <%= collection.name %></span>
<% end %>
+1 -1
View File
@@ -18,7 +18,7 @@
<div class="header__actions header__actions--end">
<% if collection = @filter.single_collection %>
<%= render "cards/collection_settings", collection: collection %>
<%= link_to_edit_collection collection %>
<% end %>
</div>
<% end %>
+1 -1
View File
@@ -15,7 +15,7 @@
</h1>
<div class="header__actions header__actions--end">
<%= render "cards/collection_settings", collection: @collection %>
<%= link_to_edit_collection @collection %>
</div>
<% end %>