Get parent model


#1

Hello,

For some reason I cannot get parent model, I’m creating a wizard form.

this.resource("notes", function() {
  this.resource('notes.new', function() {
    this.route('first')
  })
});

Here is my routes.

App.NotesNewRoute = Ember.Route.extend({
  model: function() {
    return this.store.createRecord('note');
  },
  actions: {
    gotoFirst: function() {
      this.transitionTo('notes.new.first')
    }
  }
});

App.NotesNewIndexRoute = Ember.Route.extend({
  model: function() {
    return this.modelFor('notes.new');
  }
});
App.NotesNewFirstRoute = Ember.Route.extend({
  model: function() {
    return this.modelFor('notes.new');
  },
  setupController: function(controller, model) {
    var contacts = this.store.find('contact')
    this.controller.set('contacts', contacts)
  }
});

It’s weird that “notesNewIndex” get the parent model, but not “newFirstRoute”.

I think the problem is in the setupController, because I set contacts array, then the controllers need to be ArrayController, and then the model never get attached on the view.


#2

For some reason I must set the model in the setupController.

App.NotesNewFirstRoute = Ember.Route.extend({
  setupController: function(controller, model) {
    var contacts = this.store.find('contact')
    controller.set('model', this.modelFor('notes.new'))
    controller.set('contacts', contacts)
  }
});

and not in the model function?