Reputation: 44501
Using the REST Adapter
, it is possible to have embedded objects by doing:
App.Adapter.map('App.User', {
properties : {embedded: 'always'},
});
How do I declare embedded objects using a FIXTURE
? I have tried specifying this in the model:
App.User = DS.Model.extend({
properties : DS.belongsTo('App.UserProperties', { embedded : true })
});
But this is not working. Is it possible to have embedded objects using FIXTURES
? My FIXTURE
looks like:
App.User.FIXTURES = [
{
id: 'id1',
type: 'user',
properties : {
name: 'Max Smith',
email: '[email protected]' }
},
];
Upvotes: 1
Views: 535
Reputation: 23322
The FixtureAdapter
does not support embedded records, the only way to do this is to define FIXTURES
for your UserProperties
model as well:
App.User.FIXTURES = [
{
id: 'id1',
type: 'user',
properties : 1
];
App.UserProperties.FIXTURES = [
{
id: '1',
name: 'Max Smith',
email: '[email protected]'
}
];
Here also a quick statement from @tomdale (one of the creator of ember-data) on the FixtureAdapter
I do not believe that fixture adapter supports embedded records is there a good reason why it would need to? it also doesn't support underscored_property_names the idea of the fixture adapter is not to mimic the JSON payload from the server it is provide stub data in the format Ember Data expects so relationships are not embedded, property names are camelCased, etc.
Hope it helps.
Upvotes: 2