我有以下燼型號:堅持燼模型的嵌入式記錄
App.Location = DS.Model.extend({
street: DS.attr('string'),
city: DS.attr('string'),
area: DS.attr('string'),
lat: DS.attr('string'),
lng: DS.attr('string'),
report: DS.belongsTo('report', {embedded: 'always'})
});
App.Report = DS.Model.extend({
title: DS.attr('string'),
description: DS.attr('string'),
reg_num: DS.attr('string'),
location_str: DS.attr('string'),
location: DS.belongsTo('location', {embedded: 'always'})
});
在App.ReportController
,當我嘗試保存的報告我也想嵌入請求負載的位置對象。到目前爲止,我嘗試下面的代碼:
App.ReportController = Ember.ObjectController.extend({
actions: {
saveReport: function(record) {
var self = this,
report = this.get('model'),
location = this.store.createRecord('location', {
lat: this.get('lat'),
lng: this.get('lng')
});
report.set('location', location);
report.save().then(function (result) {
self.transitionToRoute('list');
});
}
}
}
});
然而,在請求負載位置始終location: null
。
如何將location
添加到請求負載?
什麼版本的燼數據和你使用什麼串行器? – Microfed 2014-10-07 10:06:05
DEBUG:Ember數據:1.0.0-beta.7.f87cba88 – 2014-10-07 18:11:43