Quantcast
Channel: Ember.JS - Latest topics
Viewing all articles
Browse latest Browse all 4828

Add belongsTo ID attribute to payload on create/update

$
0
0

@bschaeffer wrote:

Is there a way to add a models belongsTo id attribute to the payload when creating/updating the model? I am using JSONAPISerializer ATM but can't find anything on the webs about how to accomplish this. Here's an example:

Category = DS.Model.extend({});

Thing = DS.Model.extend({
  name: DS.attr(),
  category: DS.belongsTo('category')
});

// Route
thing = this.get('store').createRecord('thing', {
  name: 'Bananas',
  category: getPreviouslySaved()
});

thing.save(); // category_id is missing from the create payload

Where or how do I add category_id to the payload?

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4828

Trending Articles