2
votes

I am migrating from EMber data 0.13 to 1.0.0 beta. According to the documentation (https://github.com/emberjs/data/blob/master/TRANSITION.md), the following should work:

App.AuthorsNewRoute = Ember.Route.extend({

  model: function () {
    return this.store.createRecord('author');
  },

  actions: {
    save: function() {
      this.modelFor('author').save();
    }
  }
})

However, in my case, I always get a "Cannot call method 'save' of undefined" error".

When using "this.get('currentModel').save();", it works when using the save action in the route. When putting the save action in the controller, it no longer works. Same error: Cannot call method 'save' of undefined" error.

How can I access the newly created record in the controller and save it ?

Can somebody provide a simple example ?

thx Marc

1

1 Answers

5
votes

You right to use this in the route :

this.get('currentModel').save();

In the controller you should use :

this.get('model').save();