当我保存一个块(属于多维数据集)时,会保存belongsTo
关系,但不会保存多维数据集的hasMany
关系。创建阻止后,没有PUT请求被发送到服务器以更新多维数据集。
块模型:
export default DS.Model.extend({
name: DS.attr(),
description: DS.attr(),
cube: DS.belongsTo('cube')
});
立方体模型:
export default DS.Model.extend({
name: DS.attr(),
description: DS.attr(),
blocks: DS.hasMany('block', { async: true })
});
保存阻止:
var name = this.get('name');
var description = this.get('description');
var cube = this.store.peekRecord('cube', this.model.id);
if (!name) {return;}
this.store.createRecord('block', {
name: name,
description: description,
cube: cube
})
.save()
.then(function() {
this.resetForm();
var name = slugify(this.model.get('name'));
this.transitionToRoute('cubes.show', this.model.get('id'), name);
}
.bind(this));