Search code examples
ember.jsember-data

Update ember 2.6.2 to 2.7.0 - Uncaught TypeError: Cannot read property 'eachAttribute' of undefined


  • ember@2.6.2 to ember@2.7.0
  • ember-data@2.9.0 (however same error when running under 2.5.x)

The following was worked fine before the update.

Getting the following error: Uncaught TypeError: Cannot read property 'eachAttribute' of undefined

I am reloading a model this.modelFor('admin').get('ssoApplicationSubscriptions').reload();

When it starts executing the eachAttribute loop I get the error. Interestingly the constructor is undefined at this point.

enter image description here

Here are the model definitions

// Organisation
export default DS.Model.extend({
  name: attr('string')
});

// Institution Organisation
export default Organisation.extend({
  ssoApplicationSubscriptions: hasMany('sso-application-subscription', { polymorphic: true })
});

I am using the JSONAPIAdapter/Serializer.


Solution

  • I was having the same issue with this one and it came down to me using the constructor to get the model name of the polymorphic model. in my case I have emails and emails belong to a promotion, which is polymorphic so it looked like this:

    {{email.promotion.content.constructor.modelName}}

    and what I did to change it was this: I added promotion_type: DS.attr("string") to my Email Model

    and change the template to use that attr: {{email.promotion_type}}