Module: MobileWorkflow::Attachable

Extended by:
ActiveSupport::Concern
Included in:
ApplicationRecord
Defined in:
app/models/concerns/mobile_workflow/attachable.rb

Instance Method Summary collapse

Instance Method Details

#attachment_url(attachment) ⇒ Object



18
19
20
21
22
# File 'app/models/concerns/mobile_workflow/attachable.rb', line 18

def attachment_url(attachment)
  return nil unless attachment.attached?

  rails_blob_url(attachment, host: attachment_host)
end

#preview_url(attachment, options: { resize_to_fill: [200, 200] }) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'app/models/concerns/mobile_workflow/attachable.rb', line 8

def preview_url(attachment, options: { resize_to_fill: [200, 200] })
  return nil unless attachment.attached?

  if attachment.image?
    rails_representation_url(attachment.variant(options), host: attachment_host)
  elsif attachment.previewable?
    rails_representation_url(attachment.preview(options), host: attachment_host)
  end
end