title: Rails Ajax form submits twice
body: <p>I have a form that is rendered via ajax.  The form also submits with ajax.  When the form is submitted, it does a post request twice.  </p>
  
  <p>When someone clicks the "create profile" link, the form is rendered via ajax next to the link.  When the form is displayed, I need to include some javascript at the beginning of the view file in because the form requires these js files.  Here is the form:</p>
  
  <pre><code>&lt;%= javascript_include_tag "/assets/temp_js/jquery-1.8.3.min.js" %&gt;
  &lt;%= javascript_include_tag "/assets/jquery_ujs.js" %&gt;
  &lt;%= javascript_include_tag "/assets/temp_js/jquery.jscrollpane.min.js" %&gt;
  &lt;%= javascript_include_tag "/assets/temp_js/jquery.c2selectbox.js" %&gt;
  &lt;%= javascript_include_tag "/assets/temp_js/jquery.colorbox-min.js" %&gt;
  &lt;%= javascript_include_tag "/assets/temp_js/functions.js" %&gt;
  
  &lt;%= form_for @profile, :html =&gt; { :class =&gt; "clearfix" }, remote: true do |f| %&gt;
      &lt;%= f.text_area :description, :title =&gt; "Describe yourself and what you do." %&gt;
      &lt;%= f.file_field :pic, :class =&gt; "field file-field", :id =&gt; "file" %&gt;
  &lt;%= f.submit "SAVE" %&gt;
  </code></pre>
  
  <p>The files were already loaded on the page in the application.html.erb file, but they need to be loaded again when the form is displayed because elements in the form require the javascript.  The only problem is that the two top javascript files are for some reason causing the form to post twice.  I can''t get rid of them because the form needs them, but the form submits twice with them.  Does anyone know how to fix this?</p>
  
  <p>I've seen some stack overflow pages saying I should delete the js files in my assets folder, but i need them for the form.  I've also read that Adding "config.serve_static_assets = false" to development.rb will fix the problem, but it does not.</p>
  
  <p>Thanks in advance.</p>
  
  <p>UPDATE:</p>
  
  <p>The problem definitely has to do with the jquery_ujs.js file.  If I remove that from the form code above, it does not execute twice.</p>