dimanche 3 mai 2015

ember data array of another model

I have a model called Error:

import DS from 'ember-data';
export default DS.Model.extend({
  //...
});

And a model Session which needs to contain an array of errors - but the data from the API server doesn't contain session_id so I can't use hasmany
(the errors are retrieved via query_param)

So I have:

export default DS.Model.extend({
    //...
    sessionErrors: DS.attr()
});

The route is:

export default Ember.Route.extend(
{
  model: function(params) {
    return Ember.RSVP.hash({
      session: this.get('store').find('session', params.session_id),
      sessionErrors: this.store.find('error',{session_id: params.session_id})

    });
  }
});

But I'm getting an Undefined in sessionErrors

How can I fill sessionErrors?




Aucun commentaire:

Enregistrer un commentaire