# Assertion Failed: You need to pass a model name to the store's modelFactoryFor

**URL:** <https://discuss.emberjs.com/t/assertion-failed-you-need-to-pass-a-model-name-to-the-stores-modelfactoryfor/13788>\
**Category:** Ember Data\
**Created:** [October 20, 2017, 7:07pm UTC](https://discuss.emberjs.com/t/assertion-failed-you-need-to-pass-a-model-name-to-the-stores-modelfactoryfor/13788 "2017-10-20T19:07:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kamillacrozara](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/kamillacrozara/32/17149_2.png) [@kamillacrozara](https://discuss.emberjs.com/u/kamillacrozara)\
**Post date:** [October 20, 2017, 7:07pm UTC](https://discuss.emberjs.com/t/assertion-failed-you-need-to-pass-a-model-name-to-the-stores-modelfactoryfor/13788/1 "2017-10-20T19:07:30Z")

</div>

Hey there!

I have these models that has belongsTo relationships:

```auto
//app/models/primary.js
export default DS.Model.extend(Validations, {
  number: DS.attr('string'),
  protocolDate: DS.attr('date'),
  document: DS.belongsTo('document'),
  origin: DS.belongsTo('origin')
});

```

```auto
//app/models/document.js
export default DS.Model.extend(Validations, {
  number: DS.attr('string'),
  name: DS.attr('string')
});

```

```auto
//app/models/origin.js
export default DS.Model.extend(Validations, {
  number: DS.attr('string')
});

```

And these serializers:

```auto
//app/serializers/application.js
import Ember from 'ember';
import DS from 'ember-data';

export default DS.RESTSerializer.extend({
  normalizeSingleResponse(store, primaryModelClass, payload, id, requestType) {
    var typeKey = primaryModelClass.modelName;
    return this._normalizeResponse(store, primaryModelClass, payload, id, requestType, true);
  },
  
  normalizeArrayResponse(store, primaryModelClass, payload, id, requestType) {
    var pluralTypeKey = Ember.Inflector.inflector.pluralize(primaryModelClass.modelName);
    return this._normalizeResponse(store, primaryModelClass, payload, id, requestType, false);
  },

  serializeIntoHash: function(hash, type, record, options) {
    Ember.merge(hash, this.serialize(record, options));
  },

  keyForAttribute(attr) {
    return Ember.String.camelize(attr);
  }

});

```

```auto
//app/serializers/primary.js
import DS from 'ember-data';
import ApplicationSerializer from './application';

export default ApplicationSerializer.extend(DS.EmbeddedRecordsMixin, {
  attrs: {
    document: {
      embedded: 'always'
    },
    origin: {
      embedded: 'always'
    },
  }

});

```

```auto
//app/serializers/document.js
import DS from 'ember-data';
import ApplicationSerializer from './application';

export default ApplicationSerializer.extend(DS.EmbeddedRecordsMixin, {
});

```

```auto
//app/serializers/origin.js
import DS from 'ember-data';
import ApplicationSerializer from './application';

export default ApplicationSerializer.extend(DS.EmbeddedRecordsMixin, {
});

```

But I’m still getting the error: `Assertion Failed: You need to pass a model name to the store's modelFactoryFor method Error`

I’m not sure why I’m getting this error. Here’s my payload:

```auto
{
    "primary": {
        "id": "2",
        "protocol_date": "2017-09-25 06:00:00",
        "number": "123452017",
        "document": {
            "id": "2",
            "number": "12321321",
            "name": "Tipo 2 Documento Originário"
        },
        "origin": {
            "id": "3",
            "number": "45682017"
        }
    }
}

```

My guess is that I have to change my payload to fit the JSON payload conventions, but I don’t want to change my API. Do you have any idea how could I fix this? Thank you all!

---

<div class="post-metadata">

**Author:** ![skaterdav85](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/skaterdav85/32/18291_2.png) [@skaterdav85](https://discuss.emberjs.com/u/skaterdav85)\
**Post date:** [October 22, 2017, 2:23am UTC](https://discuss.emberjs.com/t/assertion-failed-you-need-to-pass-a-model-name-to-the-stores-modelfactoryfor/13788/2 "2017-10-22T02:23:20Z")

</div>

Want to set up a twiddle?

---

<div class="post-metadata">

**Author:** ![kamillacrozara](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/kamillacrozara/32/17149_2.png) [@kamillacrozara](https://discuss.emberjs.com/u/kamillacrozara)\
**Post date:** [October 24, 2017, 6:55pm UTC](https://discuss.emberjs.com/t/assertion-failed-you-need-to-pass-a-model-name-to-the-stores-modelfactoryfor/13788/3 "2017-10-24T18:55:20Z")

</div>

Thank you! I did manage to solve this issue. I had to work on the ` modelNameFromPayloadKey` method to make it return the correct model name whether it is pluralized or not.
