demarches-normaliennes/app/models/attestation.rb

19 lines
528 B
Ruby
Raw Normal View History

2017-06-02 14:30:26 +02:00
class Attestation < ApplicationRecord
belongs_to :dossier
mount_uploader :pdf, AttestationUploader
2019-07-31 16:09:28 +02:00
has_one_attached :pdf_active_storage
2019-07-31 16:09:28 +02:00
def pdf_url
if pdf_active_storage.attached?
Rails.application.routes.url_helpers.url_for(pdf_active_storage)
elsif Rails.application.secrets.fog[:enabled]
2019-07-31 16:09:28 +02:00
RemoteDownloader.new(pdf.path).url
elsif pdf&.url
# FIXME: this is horrible but used only in dev and will be removed after migration
File.join(LOCAL_DOWNLOAD_URL, pdf.url)
end
end
2017-06-02 14:30:26 +02:00
end