Fixtures won't hook up with Ember CLI

I'm struggling to reproduce the official Getting Started TodoMVC app with Ember CLI.

I'm stuck at Using Fixtures. Fixtures just won't load any data.

The app runs fine with no errors and no records. I open the Ember Inspector and i see that my model exists but has no records.

enter image description here

Here's my app's code for you to test: github.com/lolmaus/ember-cli-fixtures-problem-demo .

Below is the code.

/app/app.js

Unmodified Ember CLI boilerplate.

/app/router.coffee

`import Ember from 'ember'`
`import config from './config/environment'`

Router = Ember.Router.extend
  location: config.locationType

Router.map ->
  @resource 'todos', path: '/'

`export default Router`

/app/routes/todo.coffee

`import Ember from "ember"`

TodoRoute = Ember.Route.extend
  model: -> @store.find 'todo'


`export default TodoRoute`

/app/adapters/application.coffee

`import DS from "ember-data"`

FixtureAdapter = DS.FixtureAdapter.extend()

`export default FixtureAdapter`

/app/models/todo.coffee

`import DS from 'ember-data'`

Todo = DS.Model.extend
  title:       DS.attr 'string'
  isCompleted: DS.attr 'boolean'

Todo.reopenClass
  FIXTURES:
    [
      id: 1,
      title: 'Learn Ember.js',
      isCompleted: true
    ,
      id: 2,
      title: '...',
      isCompleted: false
    ,
      id: 3,
      title: 'Profit!',
      isCompleted: false
    ]

`export default Todo`

PS This question is a duplicate of Ember-cli Fixture loading . I decided to start a new one because i provided a Github project for you to investigate.

Upvotes: 0

Views: 239

Answers (1)

Ok, i got this.

The resource was called todos, but the route file was called todo.coffee.

Renaming the latter to todos.coffee resolved the issue.

Upvotes: 1

Related Questions