From 8f86f8bc96607b4fe4a2be1b033fe2f8195516cb Mon Sep 17 00:00:00 2001 From: Georg Gadinger Date: Fri, 19 Aug 2022 16:33:28 +0200 Subject: [PATCH] answerbox: use ActiveSupport's String#truncate this change cuts off the answer after a word and not within one. --- app/views/application/_answerbox.haml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/views/application/_answerbox.haml b/app/views/application/_answerbox.haml index 6ad0868c..51f1fa41 100644 --- a/app/views/application/_answerbox.haml +++ b/app/views/application/_answerbox.haml @@ -5,9 +5,8 @@ .card-body - if display_all.nil? .answerbox__answer-text - = markdown a.content[0..640] + = markdown a.content.truncate(640, omission: " [...]", separator: /\s/) - if a.content.length > 640 - [...] %p %a.btn.btn-primary{ href: answer_path(a.user.screen_name, a.id) } = t(".read")