Ember数据 - 将belongsTo设置为null

时间:2014-04-10 07:48:06

标签: ember.js ember-data

我有以下型号:

App.User = DS.Model.extend({
    name: DS.attr(),
    profile: DS.belongsTo('profile')
});
App.Profile = DS.Model.extend({
    item: DS.attr()
});

我想从用户中删除配置文件,但不应删除配置文件本身。我试过了:

var user = this.modelFor('user');
user.set('profile',null);
user.save();

但是,PUT/user/{id}仍包含个人资料ID。如何删除此特定对象的关系?

1 个答案:

答案 0 :(得分:1)

在您的情况下,profile_id以nil发送。如果要从用户模型中完全删除配置文件,请扩展或重新打开序列化程序,如果它是零,则跳过配置文件。

相关问题