title: How to upload multiple files with carrierwave and create multiple records
body: <p>I am trying to modify my image upload routine in order to upload multiple images at the same time. Currently I am able to upload multiple images, but it creates only one record. How can I achieve it that one submit creates multiple records?</p>
  
  <p>I do not want to go through an association, but instead be able to directly upload multiple images.</p>
  
  <p>I currently have a Model:</p>
  
  <pre><code>class Diapo &lt; ApplicationRecord
    belongs_to :album
    mount_uploaders :file_name, DiapoUploader
  end
  </code></pre>
  
  <p>My Controller:</p>
  
  <pre><code>class Admin::DiaposController &lt; ApplicationController
  
    def new
      @diapo = Diapo.new
      @page_title = 'Create new Diapo'
    end
  
    def create
      @diapo = Diapo.new(diapo_params)
      if @diapo.save
        flash[:notice] = 'Diapo #{@diapo.file_name} was successfully created.
        redirect_to action: :index
      else
        @page_title = 'Create new Diapo'
        render action: :new
      end
    end
  
  .
  .
  .
  
    private
  
    def diapo_params
      params.require(:diapo).permit({file_name: []}, :title, :alt, :author, :copyright, :album_id)
    end
  end
  </code></pre>
  
  <p>in the form I have:</p>
  
  <pre><code>&lt;%= f.file_field :file_name, multiple: true, class: 'form-field' %&gt;
  </code></pre>
  
  <p>Currently I get one post</p>
  
  <pre><code>Started POST "/admin/diapos" for ::1 at 2019-12-18 10:45:19 +0100
  Processing by Admin::DiaposController#create as HTML
    Parameters: {"authenticity_token"=&gt;"something==", "diapo"=&gt;{"file_name"=&gt;[#&lt;ActionDispatch::Http::UploadedFile:0x00007f9062b51a40 @tempfile=#&lt;Tempfile:/var/folders/yg/pfjwzpkx5wq9d27svk760h0h0000gn/T/RackMultipart20191218-2329-7kffxo.jpg&gt;, @original_filename="1.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"diapo[file_name][]\"; filename=\"1.jpg\"\r\nContent-Type: image/jpeg\r\n"&gt;, #&lt;ActionDispatch::Http::UploadedFile:0x00007f9062b519f0 @tempfile=#&lt;Tempfile:/var/folders/yg/pfjwzpkx5wq9d27svk760h0h0000gn/T/RackMultipart20191218-2329-o5qzhe.jpg&gt;, @original_filename="2.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"diapo[file_name][]\"; filename=\"2.jpg\"\r\nContent-Type: image/jpeg\r\n"&gt;], "alt"=&gt;"Test", "author_ids"=&gt;"", "album_id"=&gt;"124", "copyright"=&gt;"Test"}, "commit"=&gt;"Save"}
    Admin Load (0.4ms)  SELECT 'admins'.* FROM 'admins' WHERE 'admins'.'id' = 1 ORDER BY 'admins'.'id' ASC LIMIT 1
  Unpermitted parameter: :author_ids
  (0.2ms)  BEGIN
    ↳ app/controllers/admin/diapos_controller.rb:14:in `create'
    Album Load (0.3ms)  SELECT `albums`.* FROM `albums` WHERE `albums`.`id` = 124 LIMIT 1
    ↳ app/controllers/admin/diapos_controller.rb:14:in `create'
    Diapo Create (0.2ms)  INSERT INTO `diapos` (`file_name`, `alt`, `copyright`, `album_id`, `created_at`, `updated_at`) VALUES ('[\"1.jpg\", \"2.jpg\"]', 'Test', 'Test', 124, '2019-12-18 09:45:34.406410', '2019-12-18 09:45:34.406410')
    ↳ app/controllers/admin/diapos_controller.rb:14:in `create'
     (6.5ms)  COMMIT
    ↳ app/controllers/admin/diapos_controller.rb:14:in `create'
  Redirected to http://localhost:3000/admin/diapos
  Completed 302 Found in 15350ms (ActiveRecord: 7.5ms | Allocations: 75512)
  </code></pre>
  
  <p>and 1 record is created which has the array of filenames in the filename field.</p>
  
  <p>I suspect I can do it either in the controller or through javascript? How would I do this?</p>
  
  <p>Thank you in advance!</p>