vendredi 25 septembre 2015

Ember Test Failed: "found no inverse relationships.."

I'm receiving an error on the test for my contact-info model. The error is

Assertion Failed: We found no inverse relationships by the name of
'address_contact_phones, address_contact_emails, contact_emails, 
contact_phones' on the 'individual' model. This is most likely due to a 
missing attribute on your model definition.

Here is my individual model

export default DS.Model.extend({
  ...
  address_contact_phones: DS.hasMany('contact_info'),
  address_contact_emails: DS.hasMany('contact_info'),
  contact_emails: DS.hasMany('contact_info'),
  contact_phones: DS.hasMany('contact_info'),
  ...
});

Here is my contact_info model

export default DS.Model.extend({
  typecode_desc: DS.attr('string'),
  contactnum: DS.attr('string'),
  email: DS.attr('number'),
  individual: DS.belongsTo('individual', {
              inverse: ['address_contact_phones', 'address_contact_emails', 
                       'contact_emails', 'contact_phones']
  })
});

And here are the models for address_contact_phone, address_contact_email, contact_email, contact_phone

export default DS.Model.extend({
  typecode_desc: DS.attr('string'),
  contactnum: DS.attr('string'),
  email: DS.attr('number')
});

Here is the test for the contact-info model

import { moduleForModel, test } from 'ember-qunit';

moduleForModel('contact-info', 'Unit | Model | contact info', {
  needs: ['model:individual']
});

test('it exists', function(assert) {
  var model = this.subject();
  assert.ok(!!model);
});

How exactly am I supposed to write the inverse relationship on the individual model? Do I need to write something on the individual model like:

address_contact_phones: DS.hasMany('contact_info', {
                          inverse: 'address_contact_phones' })




Aucun commentaire:

Enregistrer un commentaire