3
votes

I'm certain its something small and stupid I'm missing but can't seem to get my fixtures to load. Here is I've got...

app/models/todos.js

import DS from 'ember-data';

var Todo = DS.Model.extend({
  title: DS.attr('string'),
  isCompleted: DS.attr('boolean')
});

Todo.reopenClass({
  FIXTURES: [
    {
      id: "1",
      title: 'install ember-cli',
      isCompleted: true
   }, {
     id: "2",
     title: 'install additional dependencies',
     isCompleted: true
    }, {
      id: "3",
      title: 'develop amazing things',
      isCompleted: false
  }
]});

export default Todo;

app/adapters/application.js

import DS from 'ember-data';

export default DS.FixtureAdpater.extend();

app/routes/todos.js

import Ember from 'ember';

export default Ember.Route.extend({
  model: function() {
    return this.store.all('todo');
  }
});

app/router.js

import Ember from 'ember';

var Router = Ember.Router.extend({
  location: TodosENV.locationType
});

Router.map(function() {
  this.resource('todos', { path: '/' });
});

export default Router;

Brocfile.js

var EmberApp = require('ember-cli/lib/broccoli/ember-app');

var app = new EmberApp();

app.import({
  development: 'vendor/ember-data/ember-data.js',
  production:  'vendor/ember-data/ember-data.prod.js'
}, {
  'ember-data': [
    'default'
  ]
});

module.exports = app.toTree();

I've been able to push fixture data into the views via the routes with,

this.store.push(todo: {some junk});    

but can't figure out what I'm doing wrong in model files.

Any help would be greatly appreciated, Thanks.

1
Did you figure it out? I'm trying to reproduce emberjs.com/guides/getting-started with Ember CLI and i stumbled on the same issue as you.Andrey Mikhaylov - lolmaus

1 Answers

4
votes

This just a guess, but I'm wondering if you need to change this.store.all('todo'); to this.store.find('todo');. I'm pretty sure all() will only return records that are already loaded from the store.