Embedded objects and fixtures error
My Structures have embedded Overlay objects, but Ember says, "Error: assertion failed: Unable to find fixtures for model type Sylvius.Overlay"
by kristaps_petersons
HTML
<script src="https://github.com/downloads/wycats/handlebars.js/handlebars-1.0.0.beta.6.js"></script>
<script src="http://cloud.github.com/downloads/emberjs/ember.js/ember-latest.js"></script>
<script src="http://cloud.github.com/downloads/emberjs/data/ember-data-latest.js"></script>
<script type="text/x-handlebars" data-template-name="application">
{{outlet}}
</script>
<script type="text/x-handlebars" data-template-name="home">
<h1>Home</h1>
<p>
Structures:{{structures.length}}
</p>
<ul>
{{#each structure in structures}}
<li>
ID:{{structure.id}}<br/>
Name: {{structure.name}}
Overlays: {{structure.overlays.length}}
<ul>
{{#each overlay in structure.overlays}}
<li>
View: {{overlay.vi}}
Path: {{overlay.pa}}
</li>
{{/each}}
</ul>
</li>
{{/each}}
</ul>
</script>
JavaScript
Sylvius = Ember.Application.create();
Sylvius.store = DS.Store.create({
revision: 4,
adapter: DS.fixtureAdapter
});
Sylvius.Structure = DS.Model.extend({
id: DS.attr('number'),
name: DS.attr('string'),
overlays: DS.hasMany('Sylvius.Overlay', {
embedded: true
})
});
Sylvius.Overlay = DS.Model.extend({
id: DS.attr('number'),
vi: DS.attr('string'),
pa: DS.attr('string'),
structure: DS.belongsTo('Sylvius.Structure'),
v: function() {
return this.get('vi');
}.property('vi'),
p: function() {
return this.get('pa');
}.property('pa')
});
Sylvius.Overlay.FIXTURES = [];
Sylvius.Structure.FIXTURES = [{
"id": 0,
"name": "Test Structure",
"overlays": [{
"id": 1,
"vi": "Isometric",
"pa": "blah",
"structure_id": 0
},
{
"id": 2,
"vi": "Ventral",
"pa": "Lorem",
"structure_id": 0
},
{
"id": 3,
"vi": "Ventral1",
"pa": "Lorem1",
"structure_id": 0
}
]}];
Sylvius.ApplicationController = Em.Controller.extend();
Sylvius.ApplicationView = Em.View.extend({
templateName: 'application'
});
Sylvius.HomeController = Em.ArrayController.extend({
structures: function() {
return this.get('content');
}.property('[email protected]')
});
Sylvius.HomeView = Em.View.extend({
templateName: 'home'
});
Sylvius.Router = Em.Router.extend({
enableLogging: true,
location: 'hash',
root: Em.Route.extend({
// STATES
index: Em.Route.extend({
route: '/',
connectOutlets: function(router, context) {
var appController = router.get('applicationController');
appController.connectOutlet('home', Sylvius.Structure.find());
}
})
})
});
Sylvius.initialize();