lundi 24 octobre 2016

Pass an array of records to set a hasMany relationship without the records in EmberJS?

I'm saving a new 'owner' record and have the following fields:

export default Model.extend({
    "owner": attr('string'),
    "cars": DS.hasMany('car',{async: true}),
});

In this example, I have a cars field. This would relate to the car model and show how many cars the owner has in his collection. However, let us say no cars exist, or I want to add the owner record without adding cars he owns... I get this error:

"Assertion Failed: You must pass an array of records to set a hasMany relationship"

How would I got about saving this record, so I can add cars or possibly keep with no cars?




Aucun commentaire:

Enregistrer un commentaire