title: Sending AJAX Post Jquery in rails application
body: <p>With simple controller:</p>
  
  <pre><code>  def new
      @product = Product.new
      respond_to do |format|
        format.html #new.html.erb
        format.json { render json: @product}
      end
    end
  
    def create
      @product = Product.new(params[:product])
      respond_to do |format|
        if @product.save
          format.html { redirect_to @product, notice: "Save process completed!" }
          format.json { render json: @product, status: :created, location: @product }
        else
          format.html { 
            flash.now[:notice]="Save proccess coudn't be completed!" 
            render :new 
          }
          format.json { render json: @product.errors, status: :unprocessable_entity}
        end
      end
    end
  </code></pre>
  
  <p>and simple ajax request</p>
  
  <pre><code>$("h1").click -&gt;
    $.post
      url: "/products/"
      data:
          product:
              name: "Filip"
              description: "whatever"
  
      dataType: "json"
      success: (data) -&gt;
        alert data.id
  </code></pre>
  
  <p>im trying to send new product but server answers </p>
  
  <blockquote>
    <p>[2013-07-09 18:44:44] ERROR bad URI `/products/[object%20Object]'.</p>
  </blockquote>
  
  <p>and nothing changes in database. Why instead of getting /products uri its taking prducts/[oobject] thing? Whats wrong there?</p>