dimanche 29 juillet 2018

Ember: Getting Assertion Failed error when saving persisted data

I am going through the video tutorial provided below and am unable to resolve an Assertion Failed error message (see below). Per the video tutorial, the author originally runs the save() function and gets the Assertion Failed error message. The author then instructs us to call the transitionTo() function after the save() function has been called in order to get around the error message; however, I am still receiving the error message.

In my project, I notice that the database has two new records when I click on submit, which also results in the error message. If I click on submit again then the application takes me back to the todo-items page where it shows the two records. Can anyone advise what I am doing wrong?

Current versions:

  • Ember : 3.2.2
  • Ember Data : 3.2.0
  • jQuery : 3.3.1

Video tutorial (the error occurs at the 11:30 mark): https://www.youtube.com/watch?v=bZ1D_aYGJnU

Ember Error Message

route/add.js

import Route from '@ember/routing/route';

export default Route.extend({
    model(){
        return this.store.createRecord('todo-item');
    },

    actions: {
        submitAction() {
            this.get('controller.model')
            .save()
            .then(() => {
              this.transitionTo('s.todo-items');
            });
        }
    },
});




Aucun commentaire:

Enregistrer un commentaire