Hi,
First things first. I am no native english speaker, so if I have some strange saying, I excuse myself in advance.
To the point:)
I am making the transition from Ember Data 0.13 to Ember Data 1.0.beta.6. At some points its quite easy at some, but at other points its hard to find the right practice.
I am using the ActiveModelSerializer and -adapter with a rails backend and all is quite nice yet. The Problem I get is when saving records. I need to only save dirty attributes. Excample:
user = @store.find('user', 1)
user.get('name') # prints 'sergio leone'
user.get('role') # prints 'cowboy'
user.set('role', 'chicken').save()
this should make a post request with only the changed properties:
{ user: { id: 1, role: 'chicken' }
also I dont wanna send attributes with no value. When I create a new record I send something like this, when no role is set:
{ user: { name: 'Pling', role: null }
Am I seeing it right that there is no dirt tracking included in Ember Data? I searched the source code abit and I think that the right point to handle this would be the serialize method of the ActiveModelSerializer like this:
App.ApplicationSerializer = ActiveModelSerializer.extend
serialize: (record, options) ->
json = this._super(record, options)
//check if some value is null and what attributes are dirty
return json
Am I on the right way? I am really getting headaches by searching the right point to interfere. And how can I check which attributes changed. Aint the adapter managing it?
I hope you can bring some light into my damaged head.
cheers klopfer