From e59f756c016d337cb4dbf0ebb47b320370c39541 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Wed, 29 Oct 2025 18:11:43 +0100 Subject: [PATCH] Extract explaining helper method --- app/helpers/collections_helper.rb | 6 ++++++ app/views/cards/show.html.erb | 4 +--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/helpers/collections_helper.rb b/app/helpers/collections_helper.rb index ac1debab4..8b64f0b00 100644 --- a/app/helpers/collections_helper.rb +++ b/app/helpers/collections_helper.rb @@ -1,4 +1,10 @@ module CollectionsHelper + def hotkeyed_link_to_collection(collection, &) + link_to collection, class: "header__title btn borderless txt-large", + style: "--btn-padding: 0.25ch 1ch 0.25ch 0.75ch; view-transistion-name: card-collection-title;", + data: { controller: "hotkey", action: "keydown.esc@document->hotkey#click click->turbo-navigation#backIfSamePath" }, & + end + def referenced_collections_from(records) Current.user.collections.where id: records.pluck(:collection_id).uniq end diff --git a/app/views/cards/show.html.erb b/app/views/cards/show.html.erb index dae3aaa9b..28b2476ce 100644 --- a/app/views/cards/show.html.erb +++ b/app/views/cards/show.html.erb @@ -11,9 +11,7 @@ <% content_for :header do %> <%= render "filters/menu" %> - <%= link_to collection_url(@card.collection), class: "header__title btn borderless txt-large", - style: "--btn-padding: 0.25ch 1ch 0.25ch 0.75ch; view-transistion-name: card-collection-title;", - data: { controller: "hotkey", action: "keydown.esc@document->hotkey#click click->turbo-navigation#backIfSamePath" } do %> + <%= hotkeyed_link_to_collection(@card.collection) do %> <%= @card.collection.name %>