mirror of
https://github.com/internetee/registry.git
synced 2025-07-24 03:30:33 +02:00
Add tests, fix error handling
This commit is contained in:
parent
e15b1283e5
commit
e92afb59c1
2 changed files with 26 additions and 8 deletions
|
@ -5,14 +5,11 @@ module Admin
|
|||
def show
|
||||
@ld = LegalDocument.find(params[:id])
|
||||
filename = @ld.path.split('/').last
|
||||
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
|
||||
file = File.open(@ld.path)&.read
|
||||
send_data file, filename: filename
|
||||
rescue Errno::ENOENT
|
||||
flash[:notice] = I18n.t('legal_doc_not_found')
|
||||
redirect_to [:admin, @ld.documentable]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue