vendredi 20 novembre 2015

Create a record for a model other than the current routes model

I have an items route that lists items, when I click one I go to an item route that shows the one item. Pretty standard and I've set it up such that Ember magic is taking care of the dynamic part of the item route.

In the item route I have an action handler that I want to create a bid on that item, items have many bids and bids belong to one item and one user.

In my item route I've tried just calling

  var newBid = this.store.createRecord('bid', {
          user_id: 29,
          item_id: 2565,
          bid_amt: 600
        });
  newBid.save().then(function(bid){
    console.log('saved bid\n');
    console.log(bid);
  }).catch(function(reason){
    console.log(reason)
  });

But in the console I'm getting

Uncaught TypeError: DS.default.Attr is not a function

Is there a way to do this with ember-data without having to switch to a straight Ajax call?




Aucun commentaire:

Enregistrer un commentaire