From daceb1d21c535586831af8d80140d3251fcd030e Mon Sep 17 00:00:00 2001 From: Andrew Tomaka Date: Fri, 16 Oct 2015 16:11:48 -0400 Subject: [PATCH] hack in only allowing bulk uploads of max 10 --- app/controllers/admin/evidences_controller.rb | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/app/controllers/admin/evidences_controller.rb b/app/controllers/admin/evidences_controller.rb index 14a0093..f09d268 100644 --- a/app/controllers/admin/evidences_controller.rb +++ b/app/controllers/admin/evidences_controller.rb @@ -8,11 +8,19 @@ class Admin::EvidencesController < Admin::BaseController end def create - params[:evidence][:screenshot].each do |screenshot| - Evidence.new(screenshot: screenshot).save - end + evidence = params[:evidence][:screenshot] - redirect_to admin_evidences_path, notice: 'Evidence was created' + if evidence.size > 10 + @evidence = Evidence.new + flash.now[:notice] = 'Only 10 evidence can be submitted at once' + render :new + else + evidence.each do |screenshot| + Evidence.new(screenshot: screenshot).save + end + + redirect_to admin_evidences_path, notice: 'Evidence was created' + end end def destroy