dimanche 31 janvier 2016

How to get reference to newly created record?

I have following use case: 'I create resource 'project' in action handler in a controller, after that I'd like to make a transition to a newly created route'. My intentions looks something like this:

 createNewProject: function() {
    this.store.createRecord('project', {
      title:                    this.get('title'),
      description:              this.get('description'),
      full_description:         this.get('full_description')
    }).then((project) => {
       this.transitionToRoute('projects.show', project);
    });
  }

but it doesn't work like that because createRecord doesn't return a promise as far as I know, maybe there is some work around ?

Thank you for help.




Aucun commentaire:

Enregistrer un commentaire