title: submit image with nested form in rails
body: <p>Here is my view for post</p>
  
  <pre><code>&lt;%= nested_form_for Post.new,url: {action: :create} do |f| %&gt;
  &lt;%= f.text_field :title,placeholder: 'Ad title' %&gt;
  &lt;%= f.text_area :description, :cols =&gt; 80, :rows =&gt; 20, :class =&gt; 'tinymce' %&gt;
  &lt;%= f.fields_for :image, :html =&gt; { :multipart =&gt; true, :id =&gt; "fileupload"  } do |uploads| %&gt;
  &lt;%= uploads.file_field :upload %&gt;
  &lt;button type="submit"&gt;Start upload&lt;/button&gt;
  &lt;% end %&gt;
  &lt;input type="submit" /&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>If i click <code>start upload</code> it is redirecting to <code>action: :create</code>. I need to upload images via ajax. How can i achieve it.</p>
  
  <p><strong>Edit 1</strong></p>
  
  <p>I tried this</p>
  
  <pre><code>&lt;script type="text/javascript" charset="utf-8"&gt;
    $(function () {
        $('#fileupload').submit(function(){
          alert('test');
        })
  
    });
  &lt;/script&gt;
  </code></pre>
  
  <p>But form is directly submitted to <code>action: :create</code></p>