Redirect to active_storage files when available

This commit is contained in:
Paul Chavard 2019-08-27 17:43:33 +02:00
parent 079ffadfce
commit 32563c3675
2 changed files with 10 additions and 2 deletions

View file

@ -14,8 +14,12 @@ module Instructeurs
after_action :mark_annotations_privees_as_read, only: [:annotations_privees, :update_annotations]
def attestation
if dossier.attestation.pdf_active_storage.attached?
redirect_to url_for(dossier.attestation.pdf_active_storage)
else
send_data(dossier.attestation.pdf.read, filename: 'attestation.pdf', type: 'application/pdf')
end
end
def apercu_attestation
send_data(dossier.build_attestation.pdf.read, filename: 'apercu_attestation.pdf', disposition: 'inline', type: 'application/pdf')

View file

@ -48,8 +48,12 @@ module Users
end
def attestation
if dossier.attestation.pdf_active_storage.attached?
redirect_to url_for(dossier.attestation.pdf_active_storage)
else
send_data(dossier.attestation.pdf.read, filename: 'attestation.pdf', type: 'application/pdf')
end
end
def identite
@dossier = dossier