Migrate attestation files to active_storage

This commit is contained in:
Paul Chavard 2019-08-27 17:42:52 +02:00
parent a194ffa392
commit a19b10b118
11 changed files with 289 additions and 96 deletions

View file

@ -3,8 +3,12 @@ class Attestation < ApplicationRecord
mount_uploader :pdf, AttestationUploader
has_one_attached :pdf_active_storage
def pdf_url
if Rails.application.secrets.fog[:enabled]
if pdf_active_storage.attached?
Rails.application.routes.url_helpers.url_for(pdf_active_storage)
elsif Rails.application.secrets.fog[:enabled]
RemoteDownloader.new(pdf.path).url
elsif pdf&.url
# FIXME: this is horrible but used only in dev and will be removed after migration