Api for Rails 3 create アクションを curl で手動でテストしていますが、取得し続けInternal server error(500)
ます。私は製品モデルを持っており、これがコントローラーの作成アクションと私が試したコマンドです....
#command
curl -i -H "Accept: application/json" -X POST -d "product[product_name]=dvd" http://localhost:3000/api/products
#controller
module Api
class ProductsController < ApplicationController
respond_to :json
def create
@product = Product.new(params[:product])
respond_to do |format|
if @product.save
format.html { redirect_to @product, notice: 'Product was successfully created.' }
format.json { render json: @product, status: :created, location: @product }
else
format.html { render action: "new" }
format.json { render json: @product.errors, status: :unprocessable_entity }
end
end
end
end
end
ここで何が欠けていますか?前もって感謝します。