Skip to content

Commit

Permalink
Amend message.attach to includ first
Browse files Browse the repository at this point in the history
  • Loading branch information
Katy600 committed Jul 12, 2024
1 parent 63c8f68 commit 27b844d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions app/interfaces/api/entities/document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/presenters/message_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 27b844d

Please sign in to comment.