samedi 2 avril 2016

Ember, hasMany and belongsTo doesn't work

I tried a simple emberapp to display some userdata.

My API returns me this json:

{
   "roles":[
      {
         "id":5,
         "name":"admin",
         "alias":"Administrator",
         "users":[
            {
               "id":1,
               "username":"Evolutio",
               "email":"mail@evolutio.tld",
               "display_role":"Administrator"
            }
         ]
      },
      {
         "id":2,
         "name":"user",
         "alias":"Benutzer",
         "users":[

         ]
      },
      {
         "id":1,
         "name":"banned",
         "alias":"Gesperrt",
         "users":[

         ]
      },
      {
         "id":3,
         "name":"mod",
         "alias":"Moderator",
         "users":[

         ]
      },
      {
         "id":4,
         "name":"support",
         "alias":"Supporter",
         "users":[

         ]
      }
   ]
}

my user/model.js:

import DS from 'ember-data';

export default DS.Model.extend({
  username: DS.attr('string'),
  email: DS.attr('string'),
  display_role: DS.attr('string'),

  roles: DS.belongsTo('role'),
});

and my role/model.js

import DS from 'ember-data';

export default DS.Model.extend({
  name: DS.attr('string'),
  alias: DS.attr('string'),

  users: DS.hasMany('user'),
});

With this setup I got this error in my developer console:

Error while processing route: team.index Assertion Failed: Passing classes to store methods has been removed. Please pass a dasherized string instead of undefined EmberError@

I didn't get the mistake. Maybe anyone can help me for this.




Aucun commentaire:

Enregistrer un commentaire