From a90f042caac6ae42ff44ffecfa8e1eb6b9d8212f Mon Sep 17 00:00:00 2001 From: Andrew Brown Date: Mon, 20 Feb 2017 17:46:59 +0000 Subject: [PATCH] Allow uploading more than 2 images at a time --- app/controllers/content_controller.rb | 4 ++-- app/views/content/form/images/_upload.html.erb | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/app/controllers/content_controller.rb b/app/controllers/content_controller.rb index 2cef0482..d3cbaf7d 100644 --- a/app/controllers/content_controller.rb +++ b/app/controllers/content_controller.rb @@ -106,8 +106,8 @@ class ContentController < ApplicationController end end - def upload_files image_uploads_hash, content_type, content_id - image_uploads_hash.values.each do |image_data| + def upload_files image_uploads_list, content_type, content_id + image_uploads_list.each do |image_data| image_size_kb = File.size(image_data.tempfile.path) / 1000.0 if current_user.upload_bandwidth_kb < image_size_kb diff --git a/app/views/content/form/images/_upload.html.erb b/app/views/content/form/images/_upload.html.erb index 9fc04f23..2f11bca3 100644 --- a/app/views/content/form/images/_upload.html.erb +++ b/app/views/content/form/images/_upload.html.erb @@ -1,13 +1,12 @@
<%= f.fields_for :image_uploads do |upload_form| %> - <% uuid = SecureRandom.uuid %>
<%= upload_form.label 'Select a file to upload' %>
Browse - <%= upload_form.file_field :src, name: "image_uploads[#{uuid}]" %> + <%= upload_form.file_field :src, name: "image_uploads[]" %>