title: Ruby on Rails ajax post failed
body: <p>following were my javascript where user post the updates:</p>
  
  <pre><code>$('.attachments-container').on('click', '.cover-attachment', function(event) {
                  var attachment_id = $(this).parent().find('input[name="product_attachment[id][]"]').val();
                  $.ajax({
                      type: "POST",
                      url: "/products/update_cover",
                      dataType: "json",
                      data: attachment_id,
                      complete: function(){
                          console.log('change completed');
                      }
                  });
                  event.preventDefault();
  
              })
  </code></pre>
  
  <p>On my routes:</p>
  
  <pre><code>resources :products do
          member do
              match "update_cover", via: [:post]
              post "update_cover" =&gt; 'products#update_cover'
  
          end
      end
  </code></pre>
  
  <p>On my controller:</p>
  
  <pre><code>class ProductsController &lt; ApplicationController
  skip_before_action :authenticate_user!, only: [:result, :show]
  def update_cover
          @attachment_id = params[:attachment_id]
          render :json =&gt; {:status =&gt; 'success'}.to_json
      end
  end
  </code></pre>
  
  <p>I had no clue where this error comes from: <code>ActionController::RoutingError (No route matches [POST] "/products/update_cover"):</code> Thanks!!</p>