Loading data for a route that is not part of the model

What’s a good way to load data needed for a route but not part of the model? For example let’s say I have a create user route, and the user has a department property. We need to fill a dropdown with the available departments from the database. Right now we are using a model hash and it smells bad to me.

model() {
    return RSVP.hash({
        user: store.find('user'), 
        departmentsdropdown: $.get(foo)
    });
}

data needed for a route but not part of the model

To me those are the same thing. I think the way you’re doing it is just fine and hashes are awesome. I’ve worked on a number of Ember apps at this point and we had hashes in most routes in all of them. Just because it’s called “model” doesn’t mean it needs to be singular. I think of the route’s model as something like “all the data the route needs to function properly”. Could be one thing could be 20 things.

1 Like