I've got an issue here using custom Django RF Ember-D adapter. On the initial POST request foreign keys are fine, then after trying to HTTP PUT on the same record, the FK get lost.
I've already found the problem. (I think so.)
export default DRFSerializer.extend({
serializeBelongsTo: function(snapshot, json, relationship) {
var key = relationship.key;
if (this._canSerialize(key)) {
var fkID = snapshot.belongsTo(key, { id: true });
var fkPromise = Ember.isNone(fkID) ? snapshot.record.get(key) : wrap_as_promise(fkID)
fkPromise.then(xxx)
...
}
},
On the initial request the snapshot.belongsTo(key, { id: true })
returns an ID but on the second request it returns a promise. But the method that calls serializeBelongsTo doesn't expect it to be a resolveable method. If I for instance resolve a foreignkey in the template/controller the snapshop.xx does return an id.
Aucun commentaire:
Enregistrer un commentaire