title: rails 3: jquery ajax form calling twice?
body: <p>I am seeing quite a weird behavior on a simple form:</p>
  
  <p>Here's the form:</p>
  
  <pre><code>&lt;%= form_for @product_list, :url =&gt; add_product_admin_product_list_path(@product_list, :product_id =&gt; @product), :html =&gt; {'data-remote' =&gt; true} do |f| %&gt;
    &lt;p class="&lt;%= cycle('odd', 'even') %&gt;"&gt;&lt;%= @product.short_description %&gt;&lt;/p&gt;
    &lt;%= f.submit "Add Item!" unless @product_list.products.include?(@product) %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>On the server I am seeing:</p>
  
  <pre><code>Started POST "/admin/product_lists/featured-product-list-for-guests/add_product?product_id=fisher-price-rock-a-stack" for 127.0.0.1 at Fri Nov 12 15:50:59 +0100 2010
    Processing by Admin::ProductListsController#add_product as JS
    Parameters: {"product_id"=&gt;"fisher-price-rock-a-stack", "authenticity_token"=&gt;"/p5O3g0eY/zgCTq0yL9wG5XZicHrGo/FAXvlNzfoa+s=", "utf8"=&gt;"✓", "id"=&gt;"featured-product-list-for-guests"}
  Completed 200 OK in 154ms (Views: 25.6ms | ActiveRecord: 2.5ms)
  
  
  Started POST "/admin/product_lists/featured-product-list-for-guests/add_product?product_id=fisher-price-rock-a-stack" for 127.0.0.1 at Fri Nov 12 15:50:59 +0100 2010
    Processing by Admin::ProductListsController#add_product as JS
    Parameters: {"product_id"=&gt;"fisher-price-rock-a-stack", "authenticity_token"=&gt;"/p5O3g0eY/zgCTq0yL9wG5XZicHrGo/FAXvlNzfoa+s=", "utf8"=&gt;"✓", "id"=&gt;"featured-product-list-for-guests"}
      Completed 200 OK in 125ms (Views: 24.1ms | ActiveRecord: 1.4ms)
  </code></pre>
  
  <p>Basically it is calling this twice!</p>
  
  <p>Also, in my routes I have this:</p>
  
  <pre><code>  namespace :admin do
      resources :product_lists do
        member do
          put :add_product
          put :remove_product
        end
      end
    end
  </code></pre>
  
  <p>I am a bit surprised it has to be a put (a post doesn't work) but maybe that is another question!</p>