Ember: Cannot read property 'modelName' from undefined

We use ember 1.13.5

, ember-data 1.13.7

and sails 0.11

for the backend.

Full error: Cannot read property 'modelName' of undefined at ember$data$lib$system$store$$Service.extend.serializerFor

I followed the code through dev-tools and ended up with the code shown in the image below. It shows what is modelName

defined.

enter image description here

This is the code that gets called in my controller setup.js

:

_this.store.query('business-account', {user: user.get('id')})
      .then(function(businessAccount) {
        debugger;
      }, function(err) {
        debugger;
      });

      

The above situation throws the following error:

TypeError: Cannot read property 'modelName' of undefined
at ember$data$lib$system$store$$Service.extend.serializerFor (https://192.168.10.10:4200/assets/vendor-844725f1b0311e7dd3df737ef28a9edc.js:83513:35)
at https://192.168.10.10:4200/assets/vendor-844725f1b0311e7dd3df737ef28a9edc.js:106657:34
at https://192.168.10.10:4200/assets/vendor-844725f1b0311e7dd3df737ef28a9edc.js:86465:20
at Map.forEach.cb (https://192.168.10.10:4200/assets/vendor-844725f1b0311e7dd3df737ef28a9edc.js:27626:11)
at OrderedSet.forEach (https://192.168.10.10:4200/assets/vendor-844725f1b0311e7dd3df737ef28a9edc.js:27409:11)
at Map.forEach (https://192.168.10.10:4200/assets/vendor-844725f1b0311e7dd3df737ef28a9edc.js:27630:18)
at Function.ember$data$lib$system$model$$default.reopenClass.eachRelationship (https://192.168.10.10:4200/assets/vendor-844725f1b0311e7dd3df737ef28a9edc.js:86464:83)
at DS.default.RESTSerializer.extend._extractEmbeddedRecords (https://192.168.10.10:4200/assets/vendor-844725f1b0311e7dd3df737ef28a9edc.js:106650:12)
at DS.default.RESTSerializer.extend.normalize (https://192.168.10.10:4200/assets/vendor-844725f1b0311e7dd3df737ef28a9edc.js:106635:19)
at apply (https://192.168.10.10:4200/assets/vendor-844725f1b0311e7dd3df737ef28a9edc.js:32729:18)

      

UPDATE:

I also have a model named businessAccount

app/models/business-account.js

import DS from 'ember-data';

export default DS.Model.extend({

    /////////////////////////////
  // ASSOCIATIONS 
  /////////////////////////////

  business: DS.belongsTo('business', { async: true }),
  user: DS.belongsTo('user', { async: true }),

  /////////////////////////////
  // ATTRIBUTES
  /////////////////////////////

  active: DS.attr('boolean'),
  kind: DS.attr('string'),
  ROP: DS.attr('string'),
  ssn: DS.attr('string'),
  biography: DS.attr('string'),
  totalPaidToDate: DS.attr('number'),
  phoneNumbers: DS.attr('string'),
  oneWordDescriptions: DS.attr('string'),
  modesOfTransport: DS.attr('string'),
  address: DS.attr('string'),
  availabilities: DS.attr('string'),
  exclusionTImes: DS.attr('string')
});

      

business.js

import DS from 'ember-data';

export default DS.Model.extend({

  /////////////////////////////
  // ASSOCIATIONS 
  /////////////////////////////

    businessAccounts: DS.hasMany('businessAccount', { async: true }),

  /////////////////////////////
  // ATTRIBUTES
  /////////////////////////////

  name: DS.attr('string'),
  legalBusinessName: DS.attr('string'),
  timezone: DS.attr('string'),
  emails: DS.attr('string'),
  phoneNumbers: DS.attr('string'),
  availabilities: DS.attr('string'),
  exclusionTimes: DS.attr('string'),
  holidays: DS.attr('string'),
  address: DS.attr('string')

});

      

user.js

import DS from 'ember-data';

export default DS.Model.extend({

  /////////////////////////////
  // ASSOCIATIONS 
  /////////////////////////////

  businessAccounts: DS.hasMany('businessAccount', { async: true }),

  /////////////////////////////
  // ATTRIBUTES
  /////////////////////////////

  firstName: DS.attr('string'),
  lastName: DS.attr('string'),
  email: DS.attr('string'),
  phoneNumbers: DS.attr('string'),
  secondaryContactInfo: DS.attr('string'),
  address: DS.attr('string')

});

      

json

answer from sails:

    [
  {
    "business": {
      "name": "businessName",
      "ein": null,
      "website": null,
      "primaryContact": null,
      "bankInformation": null,
      "legalBusinessName": null,
      "timezone": null,
      "emails": null,
      "phoneNumbers": null,
      "availabilities": null,
      "exclusionTimes": null,
      "holidays": null,
      "address": null,
      "archived": false,
      "id": 1,
      "createdAt": "2015-07-31T11:22:26.000Z",
      "updatedAt": "2015-07-31T11:22:26.000Z"
    },
    "user": {
      "firstName": "Monty",
      "lastName": "Lennie",
      "email": null,
      "phoneNumbers": null,
      "secondaryContactInfo": null,
      "address": null,
      "archived": false,
      "id": 1,
      "createdAt": "2015-07-31T11:22:25.000Z",
      "updatedAt": "2015-07-31T11:22:25.000Z",
      "auth": 1
    },
    "status": null,
    "kind": null,
    "active": false,
    "ROP": null,
    "ssn": null,
    "biography": null,
    "totalPaidToDate": null,
    "phoneNumbers": null,
    "oneWordDescriptions": null,
    "modesOfTransport": null,
    "address": null,
    "availabilities": null,
    "exclusionTimes": null,
    "archived": false,
    "id": 1,
    "createdAt": "2015-07-31T11:22:26.000Z",
    "updatedAt": "2015-07-31T11:22:26.000Z"
  }
]

      

+3


source to share





All Articles