I have the following model:
//order/model.coffee
Order = DS.Model.extend {
line_items: DS.hasMany 'products', {async: true}
}
At some point I want to add the some products to the order. I found that I can only add the product once, adding the same product again does not work:
//product/route.coffee
...
actions:
addToCart: (product)->
order = @modelFor 'order'
console.log order.get('line_items.length') // prints 1
order.get('line_items').pushObject product
console.log order.get('line_items.length') // prints 1
...
How can I add a model more than once to a relationship ?
Aucun commentaire:
Enregistrer un commentaire