I'm trying to load an edit form in a nested route. When I hit the URL for editing a company, /companies/87/edit, I get the edit template but instead of a single model I get: DS.RecordArray:ember314. It's an array with the one model object I want.
I noticed that ember314 is the same array getting used in the model of the companies template. I tried having CompanyEditRoute's model return {} and I can see that change reflected on the template. I'm not sure how to get only the model I want, not inside of an array.
EDIT
It looks like the nested routes are just picking up the model array off of the main route. This is strange because I confirmed each Route's model method is being called when the appropriate URL is hit.
App.Router.map(function() {
this.resource('companies', function() {
this.resource('company', { path: ':company_id' }, function() {
this.route('edit');
});
});
});
App.CompanyEditRoute = Ember.Route.extend({
model: function(params) {
return App.Company.find(params.company_id);
},
renderTemplate: function() {
this.render({into: 'application', outlet: 'modal'});
}
});
undefined
so you're basically callingApp.Company.find()
again, which is probably also your model for 'companines' – Trek GlowackimodelFor('company')
or, if you really want to trigger another find,model
has two args:params
andtransition
. The transition contains more all the params required to enter this nesting. – Trek Glowacki