Ember-Data Fixture Adapter - 向HasMany关联提交新记录会导致数组中的条目消失

时间:2013-01-29 16:32:59

标签: ember.js

我在ember-data中遇到了FixtureAdapter的问题,我在HasMany数组中添加了一条新记录但是当我尝试将其提交到商店时,该关联中的所有条目都消失了。

这似乎与RESTAdapter无关,但我想知道是否有人可以了解这里发生的事情。

我创建了一个显示问题的jsfiddle。 http://jsfiddle.net/ianpetzer/jSRLV/ 如果您选择 Facilities for Client 链接,然后创建新工厂并尝试保存。

ClientFacilitiesController中的方法负责创建和提交更改。

App.ClientsFacilitiesController = Ember.ObjectController.extend({
  create_proposed_facility: function () {
  var newFacility;
  //I have also tried this alternate code that is commented out
  //newFacility = this.store.createRecord(App.Facility);
  //newFacility.set('client', this.get('model'));
  //return this.get('facilities').pushObject(newFacility);        
  newFacility = this.get('facilities').createRecord();
  newFacility.set('client', this);
},
save: function () {
  this.store.commit();
}
});

我的问题是我是否可以修改我的代码以使其与FixtureAdapter一起使用,或者这是否是FixtureAdapter的错误。

谢谢!

1 个答案:

答案 0 :(得分:0)

FixtureAdapter实际上没有对yout FIXTURES数组进行任何更改。 但是有一个公关:https://github.com/emberjs/data/pull/728