Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ember "transition was aborted"

I have a route in my Ember App Kit project which fetches from a REST service. This is the code:

var PatientsIndexRoute = Ember.Route.extend(Ember.SimpleAuth.AuthenticatedRouteMixin, {
  model: function() {
    return this.store.find('patient').then(function(res) {
      console.log("success");
      return res;
    }, function() {
      console.log("error", arguments);
    });
  }
});

export default PatientsIndexRoute;

However when I navigate to the route (/patients/index in this case) the page appears to do nothing. Here is the console:

23:09:46.946 OPTIONS http://localhost:7000/patients/ [HTTP/1.0 200 OK 1ms]
23:09:46.881 "Attempting transition to patients.index" ember.js:3450
23:09:46.883 "Transition #3: patients.index: calling beforeModel hook" ember.js:3450
23:09:46.883 "Transition #3: patients.index: calling deserialize hook" ember.js:3450
23:09:46.948 GET http://localhost:7000/patients/ [HTTP/1.0 200 OK 4ms]
23:09:46.911 "success" app.js:171
23:09:46.912 "Transition #3: patients.index: calling afterModel hook" ember.js:3450
23:09:46.912 "Transition #3: Resolved all models on destination route; finalizing transition." ember.js:3450
23:09:46.915 "generated -> controller:patients.index" [object Object] ember.js:3450
23:09:46.918 "Transition #3: patients.index: transition was aborted" ember.js:3450

Notice transition was aborted: this is a generic message shown whenever the transition is aborted, however I can not determine where the transition was aborted from. I don't think it's being aborted while fetching the model, but some time after afterModel or setupController.

Interestingly, if I remove the model function it will navigate to the route. Also weird: it renders the wrapping template templates/patients.hbs but not the templates/patients/index.hbs template.

EDIT 1: Here is the router:

var Router = Ember.Router.extend(); /

Router.map(function() {
  // Auth-example
  this.route('index', { path: '/' });
  this.route('protected');
  this.route('login');
  this.resource('patients', function() {
    this.route('new');
  });
});

export default Router;
like image 510
samuraisam Avatar asked Feb 02 '14 07:02

samuraisam


1 Answers

My problem was that I was missing a "patients.hbs" template - where I had a "patients/new.hbs" and "patients/index.hbs". Would have been nice for it to complain about that or be a little more specific.

like image 155
samuraisam Avatar answered Oct 17 '22 15:10

samuraisam