This.store.find(..) is not working in controller


#1
I have two models say student,project. In MyRoute i set student as model so that i can get it in the MyController using "this.get('model')". But i want to get project details in MyController. How can i achieve this ? @tarasm 

#2

What do you mean its not working?

What error are you getting?


#4

Please, read this http://www.chiark.greenend.org.uk/~sgtatham/bugs.html or something similar and respond with an answer that would help me help you.


#6
 Nice one. Thanks. Ill follow before post a doubt or bug 

#7

The simplest way is to make an additional request in your Route#setupController.


Ember.StudentRoute = Ember.Route.extend({
  setupController: function(controller, model) {
    // will perform the default behaviour which will load your controller with the model.
    this._super.apply(this, arguments);
    
    // perform your Ember Data query or other AJAX request
    this.store.find('project').then(function(result){
       // handle the result and load it into the controller
       controller.set('projects', result);
    }, function(error) {
       // handle the errors
    });
  }
});