让部分ember-data属性不保存到服务器

 •  Filed under ember

在ApplicationSerializer中添加

App.ApplicationSerializer = DS.RESTSerializer.extend({
  serializeAttribute: function(record, json, key, attribute) {
    if (!attribute.options.readOnly) {
      return this._super(record, json, key, attribute);
    }
  }
});

然后再其他model中就可以

App.User = DS.Model.create({
  admin: DS.attr('boolean', { readOnly: true })
})