From 981133ca129d286961ca96d48734ab28d00a597a Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Fri, 23 Dec 2016 13:42:30 +0100 Subject: [PATCH 1/2] Fix license presence check --- app/controllers/admin/licenses_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/admin/licenses_controller.rb b/app/controllers/admin/licenses_controller.rb index efd358000cd567..7241dc0c25984d 100644 --- a/app/controllers/admin/licenses_controller.rb +++ b/app/controllers/admin/licenses_controller.rb @@ -17,7 +17,7 @@ def new end def create - unless params[:license] + unless license_params.values_at(:data, :data_file).any?(&:present?) flash.now[:alert] = "No license was selected." @license = License.new -- GitLab From 2294d9f85142cd969692717a1cd39ee4b64f1f7e Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Fri, 23 Dec 2016 13:42:42 +0100 Subject: [PATCH 2/2] Sneak ::UploadedFile past StrongParameters --- app/controllers/admin/licenses_controller.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/controllers/admin/licenses_controller.rb b/app/controllers/admin/licenses_controller.rb index 7241dc0c25984d..966dab52d7f04b 100644 --- a/app/controllers/admin/licenses_controller.rb +++ b/app/controllers/admin/licenses_controller.rb @@ -63,8 +63,15 @@ def require_license end def license_params - license_params = params.require(:license).permit(:data_file, :data) - license_params.delete(:data) if license_params[:data_file] + license_params = params.require(:license).permit(:data) + + # Wiggle around StrongParameters because data_file is an ::UploadedFile + data_file = params[:license][:data_file] + if license_params.permitted? && data_file.present? + license_params.delete(:data) + license_params[:data_file] = data_file + end + license_params end end -- GitLab