修改数组中的特定记录(方法PUT)

时间:2015-11-27 09:52:31

标签: ember.js ember-data

我有模特"用户"我有一个包含一系列对象的模型:

{users: [
 {
   id: 1,
   name: user1,
   status: new
 },
{
   id: 2,
   name: user2,
   status: new
 },
...
]}

但是,我必须改变单个用户的状态。我试试:

 actions: {
    checkAccept(id) {
      this.store.findRecord('user', id).then((record) => {
        record.set('status', 'accepted');
        record.save();
      });
 }

如果使用record.DestroyRecord,使用相同的方法删除录制作品。为什么改为PUT方法发送GET ???

已更新 我正在使用:

actions: {
 checkAccept(record) {
   this.store.adapterFor('userNetwork').updateRecord(this.store, this.userNetwork.type, record);
 }
}

但是得到了这个错误:

Uncaught Error: Assertion Failed: The `attr` method is not available on DS.Model, a DS.Snapshot was probably expected. Are you passing a DS.Model instead of a DS.Snapshot to your serializer

0 个答案:

没有答案