Access to record's changed attributes in the RESTAdapter

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?

Is your intention to format the payload or only save dirty attributes or both?

Both. It seems that Ember saves the model on the client store prior to posting it to the server. Hence, I’m unable to discover the dirty attributes in the REST adapter functions.

I want the payload I send to the server to persist to only contain changed attributes and not the entire model record.

For payload formatting I think you want the serializer.

For the dirty thing this maybe of interest

Thanks. That might just be what I need. I’ll give it a try.