Take the 2-minute tour ×

I have the following route structure

App.Router.map(function(match) {
    this.route("days", { path: "/" });
    this.resource("day", { path: "/:day_id" }, function() {
        this.resource("appointment", { path: "/appointment" }, function() {
            this.route("edit", { path: "/edit" });

When I'm inside the AppointmentIndexRoute I'm looking for a way to create a new model using some meta day from the day (parent) model but because the day model does not yet know about this appointment I'm unsure how to associate them until the appointment is created / and the commit is fired off.

Any help would be much appreciated

share|improve this question
add comment

1 Answer

up vote 13 down vote accepted

From within the AppointmentIndexRoute's model hook you can use modelFor('day') to access the parent model. For example:

App.AppointmentIndexRoute = Ember.Route.extend({
  model: function(params) {
    day = this.modelFor("day");

Another example is here: emberjs 1.0.0pre4 how do you pass a context object to a resource "...Index" route?

share|improve this answer
I love it when it's that simple -thanks for the blazing fast reply! –  Toran Billups Feb 5 '13 at 14:31
add comment

Your Answer


