From dd42725402e33e4b19a2e30723635f70d0c0b562 Mon Sep 17 00:00:00 2001 From: Andrew Tomaka Date: Fri, 16 Oct 2015 14:45:17 -0400 Subject: [PATCH] Bulk evidence uploading --- app/controllers/admin/evidences_controller.rb | 10 ++++------ app/views/admin/evidences/_form.html.slim | 4 ++-- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/app/controllers/admin/evidences_controller.rb b/app/controllers/admin/evidences_controller.rb index 0631a81..14a0093 100644 --- a/app/controllers/admin/evidences_controller.rb +++ b/app/controllers/admin/evidences_controller.rb @@ -8,13 +8,11 @@ class Admin::EvidencesController < Admin::BaseController end def create - @evidence = Evidence.new(evidence_params) - - if @evidence.save - redirect_to admin_evidences_path, notice: 'Evidence was created' - else - render :new + params[:evidence][:screenshot].each do |screenshot| + Evidence.new(screenshot: screenshot).save end + + redirect_to admin_evidences_path, notice: 'Evidence was created' end def destroy diff --git a/app/views/admin/evidences/_form.html.slim b/app/views/admin/evidences/_form.html.slim index 9f5609f..d910f58 100644 --- a/app/views/admin/evidences/_form.html.slim +++ b/app/views/admin/evidences/_form.html.slim @@ -1,5 +1,5 @@ -= simple_form_for [:admin, @evidence] do |f| += simple_form_for [:admin, @evidence], html: { multipart: true } do |f| .form-inputs - = f.input :screenshot, as: :file + = f.input :screenshot, as: :file, input_html: { multiple: 'multiple' } .form-actions = f.button :button