mercredi 2 septembre 2015

Routing error with ember-data 2.0 and emberjs 2.0.1

Cross-posting from discuss.ember. I am using Ember 2.0.1 with Ember-data 2.0 and default the default RESTSerializer generated by ember-cli. I know this question has been asked to many places before (which none have real answers) but no solutions have been working for me yet.

I have this model hook for a user model :

export default Ember.Route.extend({
    model() {
    return this.store.findAll('user');
    }
});

Router is the following :

Router.map(function() {
  this.route('users', { path: '/' }, function() {
    this.route('user', { path: '/:user_id' }, function(){
    this.route('conversations', { path: '/'}, function(){
        this.route('conversation', { path: '/:conversation_id' });
    });
    });
  });
}); 

For example, going to /conversations/4 transitions to users.user.conversations. My relations are defined in my models. In the user model I have a DS.hasMany('conversation') conversations attribute set with { embedded: 'always' }. Returned JSON looks like this :

{"conversations":[
    {
     "id":183,
     "status":"opened",
     "readStatus":"read",
     "timeAgoElement":"2015-08-20T16:58:20.000-04:00",
     "createdAt":"June 16th, 2015 20:00",
     "user":
            {
               "id":4
            }
    }
   ]}

The problem I get is that Ember-data is able to add my data to the store but I get this error :

Passing classes to store methods has been removed. Please pass a dasherized string instead of undefined

I have read these posts : #272 and #261

Is it a problem with the JSON response?

Thank you. I have been using ember-data for quite a bit of time and never encountered this error before switching to ember 2.0.1 and ember-data 2.0.0

Aucun commentaire:

Enregistrer un commentaire