I'm using EmberJS 1.13.3, EmberData 1.13.4, active-model-adapter 1.13.3 and I'm trying to load some model data from the store. The parent route makes the call to the API and works as expected, but the child route calls the API but returns with the following error:
Cannot read property '_internalModel' of undefined TypeError: Cannot read property '_internalModel' of undefined
My code looks like this:
File: routes/user.js
import Ember from 'ember';
export default Ember.Route.extend({
titleToken: function() {
return 'Profile';
},
model: function(params) {
return Ember.RSVP.hash({
user: this.store.findRecord('user', params.username)
});
},
setupController: function(controller, models) {
this._super(controller, models);
controller.setProperties(models);
}
});
File: routes/user/posts.js
import Ember from 'ember';
export default Ember.Route.extend({
titleToken: function() {
return 'Posts';
},
model: function() {
return Ember.RSVP.hash({
posts: this.store.findRecord('post', 'my_username')
});
},
setupController: function(controller, models) {
controller.setProperties(models);
}
});
The JSON response for both looks the following:
User route:
{
"user": {
"id":"1",
"username":"my_username",
"first_name":"John",
"last_name":"Doe",
"post_ids":[1, 2]
}
}
Posts route:
{
"posts":[
{ "id": 1, "author": "John Doe", "text": "My post", "username": "my_username", "user_id": 1 },
{ "id": 2, "author": "John Doe", "text": "My post2", "username": "my_username", "user_id": 1 }
]
}
And the code for router.js
Router.map(function() {
this.route('user', { path: '/:username' }, function() {
this.route('posts');
});
this.route('login');
});
Did you ever solve this issue?
RépondreSupprimerDid you ever solve this issue?
RépondreSupprimer