Is there any way to access a record’s changed attrs in the updateRecord function when I extend the RESTAdapter?
I’d like to format the payload being sent to my back-end write endpoint and am thinking the place to do it would be in the adapter’s update/createRecord functions. Am I on the right path here?
In my controller, I have:
Site.EntityController = Ember.ObjectController.extend({
actions: {
updateEntity: function() {
console.log(this.model.changedAttributes());
this.model.save();
}
}
});
In the adapter, I’d like to have something like:
// Override the default adapter with the `DS.ActiveModelAdapter` which
// is built to work nicely with the ActiveModel::Serializers gem.
Site.ApplicationAdapter = DS.RESTAdapter.extend({
updateRecord: function(store, type, record) {
var data = {}
data.uuid = record.uuid;
data.type = record.type;
data.properties = {};
_.each(record.changedAttributes(), function(elem) {
// set changed attributes in the properties map
});
// POST data to the back-end
},
createRecord: function(store, type, record) {
console.log('createRecord');
}
});
Could someone offer any advice on 1) whether I’m on the right path in doing this in the adapter and 2) how?