From ec8329069d36cc6aa444c8a48b6b34a3e8f5c9d2 Mon Sep 17 00:00:00 2001 From: erdgeist Date: Tue, 21 Jul 2026 21:34:14 +0200 Subject: Extract Page#headline_asset The same related_assets.find_by(headline: true) query was written by hand in three places -- content_helper, nodes#show, and the chapter teaser partial (which was still using assets.first, the old position-based rule, until now). Collapsed to one method, one query. --- app/views/custom/partials/_chapter.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app/views/custom') diff --git a/app/views/custom/partials/_chapter.html.erb b/app/views/custom/partials/_chapter.html.erb index 47f3950c..5d47679e 100644 --- a/app/views/custom/partials/_chapter.html.erb +++ b/app/views/custom/partials/_chapter.html.erb @@ -1,7 +1,7 @@
- <% if page.assets.images.any? %> - <%= link_to_path image_tag(page.assets.images.first.upload.url(:thumb), :alt => ""), page.node.unique_name, class: "chapter_thumbnail" %> + <% if page.headline_asset %> + <%= link_to_path image_tag(page.headline_asset.upload.url(:thumb), :alt => ""), page.node.unique_name, class: "chapter_thumbnail" %> <% end %>

<%= link_to_path page.title, page.node.unique_name %>

-- cgit v1.3