From b148ff3c5cfa837342abb9ac6297196e0c032c55 Mon Sep 17 00:00:00 2001 From: Derek Murphy Date: Tue, 26 Oct 2021 13:53:00 -0400 Subject: [PATCH 1/2] Adding a check if a document exists, redirecting to homepage with notice if it doesn't --- app/controllers/pdfviewer_controller.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/controllers/pdfviewer_controller.rb b/app/controllers/pdfviewer_controller.rb index 8df99abd..335ab606 100644 --- a/app/controllers/pdfviewer_controller.rb +++ b/app/controllers/pdfviewer_controller.rb @@ -1,7 +1,11 @@ class PdfviewerController < ApplicationController layout "pdfviewer" def index - @id = params[:id] - @parent_id = FileSet.find(@id).parent_id + if FileSet.exists?(params[:id]) + @id = params[:id] + @parent_id = FileSet.find(@id).parent_id + else + redirect_to root_path, notice: "Document not found" + end end end \ No newline at end of file From 3cc31b7a8b75d89d5806925fcca4dcd4163c52c9 Mon Sep 17 00:00:00 2001 From: Derek Murphy Date: Tue, 26 Oct 2021 16:18:48 -0400 Subject: [PATCH 2/2] changed notice to alert on redirect --- app/controllers/pdfviewer_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/pdfviewer_controller.rb b/app/controllers/pdfviewer_controller.rb index 335ab606..5a24595b 100644 --- a/app/controllers/pdfviewer_controller.rb +++ b/app/controllers/pdfviewer_controller.rb @@ -5,7 +5,7 @@ def index @id = params[:id] @parent_id = FileSet.find(@id).parent_id else - redirect_to root_path, notice: "Document not found" + redirect_to root_path, alert: "Document not found" end end end \ No newline at end of file