vendredi 2 octobre 2015

Ember Cannot read property 'createRecord' of undefined

I getting the following error when I tries to return model from the route

enter image description here

My model task.js

 //My Code for returning the model
      //My Model initialization :
        Taskmanagementfortenmiles.Task = DS.Model.extend({
          display_id: DS.attr('string'),
          type: DS.attr('string'),
          display_name: DS.attr('string'),
          isCompleted:DS.attr('boolean'),
          timestamp: DS.attr() 
        });

My Route task_route.js:

Taskmanagementfortenmiles.TaskRoute = Ember.Route.extend({

    model: function() {
     return $.getJSON("http://localhost:3000/tasks").then(function(response) {
                  var task = [];
                  var self = this;
                  response.forEach(function(task) {
                   console.log(self.store.createRecord('task', {
                        display_id: random_id,
                        type: type,
                        display_name: displayName,
                        isCompleted: false,
                        timestamp: date
                    }).save());
                }); 
                return task;
              });
  },
});

Is my version of ember data is my problem for getting the error?

Please somebody help me in this issue.

Thanks in advance

Aucun commentaire:

Enregistrer un commentaire