title: Rails button_to not working for some buttons, working for others within .each
body: <p>I'm making a list of promotions where each should be deleteable. In the view, for each promotion, I've made a button_to button that should run the delete action in the controller when it is clicked. However, all but the FIRST button work correctly. In other words, the first button doesn't work.</p>
  
  <p><em>in the promotions controller</em></p>
  
  <pre><code>  def delete
      flash[:success] = 'Your promotion has been successfully deleted!'
      redirect_to('/promotions')
    end
  </code></pre>
  
  <p><em>in the promotions view</em></p>
  
  <pre><code>&lt;% @promotions.each do |p| %&gt;
     &lt;tr&gt;
       &lt;td&gt;
         .
         .
         .
         .
       &lt;/td&gt;
       &lt;td&gt;  &lt;%= button_to "Delete" , promotions_delete_path(params:      {promo_code: p.promo_code }),
       method: :post, class: "btn btn-danger btn-xs" %&gt;&lt;/td&gt;
  
       &lt;% end %&gt;
  </code></pre>
  
  <p>I really don't understand why this is happening. Every button but the first reloads the page and renders the flash successfully. The same thing was happening when I attempted to use the javascript confirm with it - it would work for all but the first, so I removed the confirm to see if anything changed - but I still have this issue. I also tried deleting some promotions through the controller and testing the new 'first' button - it doesn't matter what the promotion is, the first button in the list doesn't work. Any help would be appreciated!</p>