I'm developing an API with rails 3.2 and rabl.
Basically I have a model "Asset", and a very simple associated controller:
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
For each action, I have a associated ACTION.json.rabl view.
For instance, my index.json.rabl is:
object @assets
attributes :kind, :description
When I issue the following commands, the Asset object is created but with null values:
curl -XPOST -d 'kind=house' 'http://localhost:3000/assets.json'
Also, where is the mapping between POST/assets.json and "create" function specified ?