rails 3.2 と rabl で API を開発しています。
基本的に、モデル「アセット」と、非常に単純な関連コントローラーがあります。
class AssetsController < ApplicationController
respond_to :json
# GET /assets.json
def index
@assets = Asset.all
end
# GET /assets/1.json
def show
@asset = Asset.find(params[:id])
end
# GET /assets/1/edit
def edit
@asset = Asset.find(params[:id])
end
# POST /assets.json
def create
@asset = Asset.new(params[:asset])
@asset.save
end
end
アクションごとに、関連付けられた ACTION.json.rabl ビューがあります。
たとえば、私の index.json.rabl は次のとおりです。
object @assets
attributes :kind, :description
次のコマンドを発行すると、Asset オブジェクトが作成されますが、値は null です。
curl -XPOST -d 'kind=house' 'http://localhost:3000/assets.json'
また、POST/assets.json と "create" 関数の間のマッピングはどこで指定されていますか?