title: Rails duplicates records when using ajax to submit the form
body: <p>My form needs to customize before submitting to the rails. SO, I use ajax to submit the form, but every time, rails doubles records. Anyone has any idea how it happens.</p>
  
  <p>my controller here:</p>
  
  <pre><code>def create
    @school_current = School.find_by_id(params[:school_id])
    @quiz = Quiz.new(params[:quiz])
    @quiz.from_params(params)
    questions = params[:quiz][:questions_attributes]
    questions.each do |index, question|
      @quiz.questions.build(question)
    end
  
    respond_to do |format|
      if @quiz.save
        format.html { render nothing: true }
      else
        format.html { render action: "new" }
      end
    end
  end
  
  
  def from_params(params)
      self.name = params[:quiz][:name]
      self.school_id = params[:school_id]
      self.description = params[:quiz][:description]
  end
  </code></pre>
  
  <p>form: </p>
  
  <pre><code>&lt;div id="quizzes"&gt;
     &lt;%= form_for([@school_current, @quiz], :remote =&gt; true) do |f| %&gt;
      &lt;div class="form-inputs" id="quiz_body"&gt;
       &lt;div class="form-group"&gt;
      &lt;label&gt;Quiz Name (required)&lt;/label&gt;
      &lt;%= f.text_field :name, class: "form-control", placeholder: "Enter quiz name here .." %&gt;
  &lt;/div&gt;
  &lt;div class="form-group"&gt;
      &lt;label&gt;Quiz Description (optional)&lt;/label&gt;
      &lt;%= f.text_area :description, :rows =&gt; 10 , :cols =&gt; 10, class: "form-control", placeholder: "Enter quiz description here .." %&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  &lt;div id="question_list"&gt;
    &lt;ol&gt;
      &lt;%= f.fields_for  :questions do |builder| %&gt;
          &lt;li class="question_field_item"&gt;&lt;%= render "question_fields", f: builder %&gt;&lt;/li&gt;
      &lt;% end %&gt;
    &lt;/ol&gt;
   &lt;/div&gt;
    &lt;div class="form-actions"&gt;
      &lt;%= f.submit "save quiz", :data =&gt; {disable_with: "Saving ..."},class: "btn btn-primary text-uppercase", id: "save_quiz" %&gt;
    &lt;/div&gt;
   &lt;% end %&gt;
  &lt;/div&gt;
  </code></pre>