jeudi 4 juin 2015

ember 1.12 findAll issue using rest, pod model over json response

I have a Rest adapter right configured and when I try:

router.js

export default Ember.Route.extend({
    model: function() {
        return this.store.find('main.user');
    }
});

I got this:

WARNING: Encountered "main.user" in payload, but no model was found for model name "mainUser" (resolved model name using plezure@serializer:-rest:.typeForRoot("main.user"))

Error while processing route:

main.user Assertion Failed: The response from a findAll must be an Array, not undefined Error: Assertion Failed: The response from a findAll must be an Array, not undefined

My Json return:

{
   "main.user": [
      { "id": "1", "name": "foo" },
      { "id": "2", "name": "bar" }
   ]
}

model.js

import DS from 'ember-data';

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

My pod are right configured, everything is fine, all works if I change to the find to a non-pod model, like this (model exists at main/):

export default Ember.Route.extend({
    model: function() {
        return this.store.find('main');
    }
});

But with 'main.user' ember is uncapable to deal with json return, using fixtures pod names works well, it's ony happens on json response.

Anyone have any ideia about this kind of issue?




Aucun commentaire:

Enregistrer un commentaire