Reputation: 2226
I am using ember-data 1.0.0-beta.4. On update it sends PUT request with following JSON
{"property": { "name":"name", "age":"22" } }
How can change my RESTAdapter to send following JSON instead of above
{ "name":"name", "age":"22" }
Please help
Thanks
Upvotes: 4
Views: 307
Reputation: 47367
create a custom serializer and override the serializeIntoHash
hook, something like this should do it (I didn't test this).
Read more about serializers here: https://github.com/emberjs/data/blob/master/TRANSITION.md
App.PropertySerializer = DS.RESTSerializer.extend({
serializeIntoHash: function(data, type, record, options) {
var root = Ember.String.decamelize(type.typeKey),
properties = this.serialize(record, options);
for(var prop in properties){
if(properties.hasOwnProperty(prop)){
data[prop] = properties[prop];
}
}
}
});
Upvotes: 2