From d8ce1ac9678d79051d232240d95e28966c8ae607 Mon Sep 17 00:00:00 2001 From: Marie-Elise Date: Wed, 10 Jan 2018 23:29:59 -0600 Subject: [PATCH] Added condition and validation message for case where user has not attached file. --- app/controllers/admin/commercials_controller.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/controllers/admin/commercials_controller.rb b/app/controllers/admin/commercials_controller.rb index 3c694246..0ac02327 100644 --- a/app/controllers/admin/commercials_controller.rb +++ b/app/controllers/admin/commercials_controller.rb @@ -57,7 +57,9 @@ module Admin def mass_upload errors = Commercial.read_file(params[:file]) if params[:file] - if errors.all? { |_k, v| v.blank? } + if errors.nil? + flash[:error] = 'No file detected. Please attach a file.' + elsif errors.all? { |_k, v| v.blank? } flash[:notice] = 'Successfully added commercials.' else errors_text = ''