title: How to use capybara with multiple forms in the one view with Rails?
body: <p>I have a Rails 3.2 project using Minitest::Spec and Capybara.</p>
  
  <p>My view contains multiple forms so I can either edit or delete the record. Sample code:</p>
  
  <pre><code>&lt;%= simple_form_for @product do |f| %&gt;  
    &lt;fieldset&gt;
    #all of my field code
      &lt;div id="form-actions" class="span12 form-horizontal"&gt;
          &lt;%= f.submit nil, :class =&gt; 'create-button', :id =&gt; 'update_product' %&gt;
          &lt;%= link_to 'Cancel', products_path, :class =&gt; 'btn' %&gt;
       &lt;/div&gt;
     &lt;/fieldset&gt;    
  &lt;% end %&gt;
  
    &lt;% if !@product.new_record? %&gt;
      &lt;div id="form-actions" class="form-horizontal"&gt;
        &lt;%= button_to "delete", @product, :confirm =&gt; "Are you sure?", :method=&gt;:delete, :class=&gt;'delete-button', :id =&gt; 'delete_product' %&gt;
      &lt;/div&gt;
  &lt;% end %&gt; 
  </code></pre>
  
  <p>In my test if I call <code>click_on "update_product"</code> (the id of the update button) the delete action of the second form is called rather than the update action.</p>