ember.js - In Ember Data how do I set a relationship field by id without it sending null to the server? -
i have order model
export default ds.model.extend({ account: ds.belongsto('account', {async: true}), address: ds.belongsto('address', {async: true}), orderitems: ds.hasmany('orderitem', {async: true}), orderstatus: ds.belongsto('orderstatus', {async: true}), specialinstructions: ds.attr('string'), creationdate: ds.attr('date') });
this has order status, has model:
export default ds.model.extend({ value: ds.attr('string'), orders: ds.hasmany('order', {async: true}) });
in order/create route use model
account , aftermodel
create new order in db straight away. want create in aftermodel this:
var order = this.store.createrecord('order', { account: model, orderstatus: 1 }); return ember.rsvp.hash({ order: order.save().then(function() { self.set('order', order); }), products: this.store.findall('product').then(function(result) { self.set('products', result); }) });
but looking @ post server ember sending orderstatus: null server.
in addition want set again later in saveorder action (on controller).
order.set('orderstatus', 3); order.save().then(function() { self.transitiontoroute('member.orders', order.get('account')); });
can way? have components want send actions save objects (looking towards ember 2.0), setting id's ideal won't want access store in component etc.
Comments
Post a Comment