samedi 11 avril 2015

How can I serialize hasMany relations with ember-data > beta15?

Until ember-beta 14, everything was going fine. I have goal and account models.


goal hasMany('account'), but account does not have or belongs to goals (not on ember, there are no reason on my app.


With a custom serializer, I had all working fine:



//serializers/goal.js

import DS from 'ember-data';

export default DS.ActiveModelSerializer.extend(DS.EmbeddedRecordsMixin, {
attrs: {
account: { serialize: 'ids' }
}
});


my post request had all I need:



...
account_ids: [1, 2, 3]
...


now I just have account_ids: []. Ember nows about my serializer, otherwise I would just have accounts, not account_ids on the request.


I tried all possible combinations from docs, with and without {async: true}, etc, nothing works.


What am I'm doing wrong?


I feel that it has something to do with the new snapshots api, but couldn't find any clue about how to work with it.


Thanks!





Aucun commentaire:

Enregistrer un commentaire