I'm using DS.FixtureAdapter and can't get related entries using DS.belongsTo
App.User = DS.Model.extend({
login: DS.attr('string'),
profile: DS.belongsTo('App.Profile')
});
App.Profile = DS.Model.extend({
fullname: DS.attr('string'),
address: DS.attr('string'),
user: DS.belongsTo('App.User')
});
App.Router.map(function() {
this.resource('user', { path: ':user_id' });
});
App.UserRoute = Ember.Route.extend({
model: function(params) {
return App.User.find(params.user_id)
}
});
Is it only a feature of Rest Adapter?
update
The fixture data is something like this:
something like this:
App.User.FIXTURES = [
{
id: 1,
login: "marlus",
profile: 1
}
];
App.Profile.FIXTURES = [
{
id: 1,
fullname: "Marlus Araujo",
address: "Rio",
user: 1
}
];
The latest version of Ember Data (1.0.0-beta4), has a new syntax for configuring a model with a fixture adapter.
App.UserAdapter = DS.FixtureAdapter.extend();
App.User.FIXTURES = [{
id: 1, firstName: 'Bob', lastName: 'Roberts'
}];
App.UsersRoute = Ember.Route.extend({
model: function() {
return this.store.find('user');
}
});
App.UserRoute = Ember.Route.extend({
model: function() {
return this.store.find('user', params.user_id);
}
});
Try:
return this.get('store').find('App.User', params.user_id);
Also, this could be helpful: http://emberjs.com/guides/models/finding-a-record/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With