title: Bad Request, bad URI 400 Error
body: <p>I'm 'ajaxing' my rails web app something I haven't done before. My goal is to add a product to the database without refreshing the page</p>
  
  <p>I have a User and Product Controller. A user in his personal page adds a product. But I'm getting an 400 Error.</p>
  
  <pre><code>Bad Request
  
  bad URI `/users/function (options) { return Utils.build_path([], ["format"],[2,[2,[7,"/",false],[6,"products",false]],[1,[2,[8,".",false],[3,"format",false]],false]], arguments); }'.
  </code></pre>
  
  <p>and also</p>
  
  <pre><code>bad URI `/users/function%20(options)%20%7B%20%20return%20Utils.build_path([],%20[%22format%22],%20[2,[2,[7,%22/%22,false],[6,%22products%22,false]],[1,[2,[8,%22.%22,false],[3,%22format%22,false]],false]],%20arguments);%20%20%7D'.
  </code></pre>
  
  <p>Product Controller code:</p>
  
  <pre><code>class ProductsController &lt; ApplicationController
  
  respond_to :html, :json
  
      def create
          @product = Product.new(product_params)
          respond_to do |format|
              if @product.save
                  format.html do
                      redirect_to '/'
                  end
                  format.json { render json: @product.to_json }
              else
                  # Add a handler for unsuccessful cases
              end
          end
  
      end
      def product_params
          params.require(:product).permit(:title, :units)
      end
  end
  </code></pre>
  
  <p>User Controller, the show method:</p>
  
  <pre><code>def show
      @user = User.find(params[:id])
      @product = Product.new
  end
  </code></pre>
  
  <p>The jQuery function that has the ajax functionality:</p>
  
  <pre><code>    $('.edit-box &gt; form input[type=submit]').click(function(e) {
          closeEdit();
          event.preventDefault();
          $.ajax({
              url: Routes.products_path,
              dataType: 'json',
              type: 'POST'
          })
       });
  </code></pre>
  
  <p>Any ideas?</p>