0

This is part of my router

App.Router.map(function () {
  this.resource('report', {path: '/noticia/:report_id'}, function() {
    this.route('pictures');
  });
});

I have defined an App.ReportPicturesController but my route App.ReportPicturesRoute insists on loading a different controller.

If I do not specify a model hook, it load the App.ReportController, and if I load the model I need (that is called comment) in loads the App.CommentController.

I've tried to set controllerName to reportPictures but it didn't work.

What I have to do to make the route load ReportPicturesController? Why is not loaded the expected controller?

EDIT: If it makes any difference, I'm using ember 1.8.1, ember-data 1.0.0-beta.12, and this is what the route looks like,

App.ReportPicturesRoute = Ember.Route.extend({
  model: function(params) {
    var report = this.modelFor('report');
    return this.store.createRecord('comment', {
      inReplyToStatus: report
    });
  }
});

EDIT2: The full source code is at https://github.com/camolin3/tweetsaster

cmolina
  • 973
  • 1
  • 11
  • 21
  • Right now I workaround this by loading `this.controllerFor('reportPictures')` on `setupController` and `renderTemplate`, but I'd like to know why it is not loading my expected controller. – cmolina Dec 03 '14 at 21:20

2 Answers2

1

It is working as expected when I try.. have a look:

http://emberjs.jsbin.com/rayoje/2/

Timo
  • 187
  • 1
  • 8
  • It doen't work when you click on `Pictures` nothing happens, and when I see the console it shows `Error while processing route: report.pictures` – cmolina Dec 03 '14 at 22:55
  • I think it is the browser: I use to develop on Firefox (v33 and v35) and I get the error, but when I test it on Chrome 39 it shows the alert :/ – cmolina Dec 03 '14 at 22:58
  • I'm not being able to reproduce what is happening, I will update jsbin to make it more like my code when I have more time. Thank you for response. – cmolina Dec 04 '14 at 15:22
0

You are missing the ReportRoute model hook implementation similar to this

App.ReportRoute = Ember.Route.extend({
    model: function(params) {
        return {id:params.report_id}; 
        //or with ember-data return this.store.find('report', params.report_id);
    }
});