title: Dropzone on Rails causing double form submission to DB
body: <p>When the "Save" button is clicked, there are two entries created. One with the :map information stored, and one missing it, both with same :name. How do I get only the complete entry to save?</p>
  
  <p>new.html.erb</p>
  
  <pre><code>&lt;%=form_for [@location, @floor], html: {class: "dropzone", multipart: true, id: "map-upload"} do |f|%&gt;
    &lt;div&gt;
      &lt;%=f.label :name%&gt;
      &lt;%=f.text_field :name%&gt;
    &lt;/div&gt;
  
    &lt;div class="fallback"&gt;
      &lt;%=f.label :map%&gt;
      &lt;%=f.file_field :map%&gt;
    &lt;/div&gt;
  
    &lt;%=f.submit "Save", id: "floor-submit"%&gt;
  &lt;%end%&gt;
  </code></pre>
  
  <p>drag-drop.js</p>
  
  <pre><code>$(document).ready(function() {
    // disable auto discover
    Dropzone.autoDiscover = false;
  
    var mapUpload = new Dropzone("#map-upload", {
      paramName: "floor[map]",
      autoProcessQueue: false,
      maxFiles: 1,
      addRemoveLinks: false,
      dictDefaultMessage: 'Drag &amp; drop a map image file here, or click here to select file to upload',
    });
  
    $('#map-upload').submit(function(e){
      mapUpload.processQueue();
    });
  });
  </code></pre>
  
  <p>Relevant part of floor_controller:</p>
  
  <pre><code>  def create
      @floor = current_user.company.locations.find(params[:location_id]).floors.create(floor_params)
  
      if @floor.save
        flash[:notice] = "Floor has been created."
        redirect_to location_floors_path
      else
        flash[:alert] = "There was an error saving the floor, please try again"
        render 'new'
      end
    end
  </code></pre>
  
  <p>model</p>
  
  <pre><code>class Floor &lt; ActiveRecord::Base
    belongs_to :location
  
    has_attached_file :map
    validates_attachment_content_type :map, :content_type =&gt; /\Aimage\/.*\Z/
  end
  </code></pre>