Domanda

I'm using EmberFire to connect my DB with my wee Ember.js app. When I call destroyRecord() I get this error:

Uncaught TypeError: Cannot read property 'replace' of undefined

Any ideas?

Here is my code:

App.MainUsersController = Ember.ArrayController.extend({
  actions: {
    delete : function(user) {
      var thisUser = this.store.find(user)
      thisUser.destroyRecord()
    }
  }
})

App.MainUsersRoute = Ember.Route.extend({
  model: function () {
    return this.store.findAll('users');
  }
});

App.Users = DS.Model.extend({});

EDIT

I've added a User model per suggested answer but I'm lost on the syntax.

App.User = DS.Model.extend({
  user: DS.store.findAll('user')
});

I tried just having store.findAll('user') but store was undefined.

Sorry, not only am I learning Ember, Emberfire, but I'm also learning EmberData. Woo

È stato utile?

Soluzione

store.find() takes a type and id and then returns a promise, so try something like this:

this.store.find('user', user).then(function(user) {
  user.destroyRecord();
});

Also, you should create an App.User model (singular) and then use store.findAll('user')

I wrote the EmberFire bindings so let me know if you have any additional questions or feedback.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top