From 27b844d802d975c93de8b9c3e8b5a6edca2313c0 Mon Sep 17 00:00:00 2001 From: Katy McCann Date: Fri, 12 Jul 2024 11:36:39 +0100 Subject: [PATCH] Amend message.attach to includ first --- app/interfaces/api/entities/document.rb | 8 ++++---- app/presenters/message_presenter.rb | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/interfaces/api/entities/document.rb b/app/interfaces/api/entities/document.rb index 3b3a4280a7..8b25df0ced 100644 --- a/app/interfaces/api/entities/document.rb +++ b/app/interfaces/api/entities/document.rb @@ -9,19 +9,19 @@ class Document < BaseEntity private def attachment - object.is_a?(ActiveStorage::Attachment) ? object : object.attachment + object.is_a?(ActiveStorage::Attachment) ? object : object.attachment.first end def url - attachment.blob.url(disposition: 'attachment') if attachment.attached? + attachment.first.blob.url(disposition: 'attachment') if attachment.first.attached? end def file_name - attachment.filename if attachment.attached? + attachment.first.filename if attachment.first.attached? end def size - attachment.byte_size if attachment.attached? + attachment.first.byte_size if attachment.first.attached? end end end diff --git a/app/presenters/message_presenter.rb b/app/presenters/message_presenter.rb index ce9604efaa..b2481885c7 100644 --- a/app/presenters/message_presenter.rb +++ b/app/presenters/message_presenter.rb @@ -8,7 +8,7 @@ def sender_is_a?(klass) def body h.tag.div do h.concat(simple_format(message.body)) - attachment_field if message.attachment.present? + attachment_field if message.attachment.first.present? end end