Add error handling if legaldoc file not found

Closes #1452
This commit is contained in:
Alex Sherman 2020-06-01 14:36:16 +05:00
parent abf228df7a
commit e15b1283e5
3 changed files with 12 additions and 1 deletions

View file

@ -5,7 +5,14 @@ module Admin
def show
@ld = LegalDocument.find(params[:id])
filename = @ld.path.split('/').last
send_data File.open(@ld.path).read, filename: filename
file = File.open(@ld.path).read
if file
send_data file, filename: filename
else
flash[:notice] = I18n.t('legal_doc_not_found')
redirect_to [:admin, @ld.documentable]
end
end
end
end

View file

@ -0,0 +1,2 @@
en:
legal_doc_not_found: "There is an error downloading legal document: file not found"

View file

@ -0,0 +1,2 @@
et:
legal_doc_not_found: "Viga juriidilise dokumendi allalaadimisel: faili ei leitud"