1
votes

I'm having this really frustrating issue where some of my ember-data fixtures don't load their seed data.

This one loads its fixtures fine:

App.Place = DS.Model.extend
  name: DS.attr('string'),
  products: DS.hasMany('App.Product'),
  logo_url: DS.attr('string')

App.Place.FIXTURES = [
  {id: 1, name: 'Whataburger', logo_url: "..."},
  {id: 2, name: 'Holiday Lanes', logo_url: "..."},
  {id: 3, name: 'IHOP', logo_url: "..."},
  {id: 4, name: 'Johnny\s Pizza House', logo_url: "..."},
  {id: 5, name: 'Chilli\'s', logo_url: "..."},
  {id: 6, name: 'Church\'s Chicken', logo_url: "..."},
  {id: 7, name: 'Starbucks', logo_url: "..."},
  {id: 8, name: 'Coldstone', logo_url: "..."},
  {id: 9, name: 'Strawns Eat Shop', logo_url: "..."}
]

This one does not load its fixtures:

App.Zoo = DS.Model.extend
  name: DS.attr('string'),
  logo_url: DS.attr('string')

App.Zoo.FIXTURES = [
  {id: 1, name: 'Foo', logo_url: "..."}
]

What is the deal? I see the model in the chrome extension and all the fields are present, just not the records. I'm using the ember-source gem with version 1.0.0-rc.7. Ember data is version 0.13.

My store is defined like:

App.Store = DS.Store.extend
  adapter: DS.FixtureAdapter.create()

My ZooRoute looks like:

App.ZooRoute = Ember.Route.extend
  model: ->
    App.Zoo.find()
2
Not sure if it helps, but did you define the Store for Fixture data? App.Store = DS.Store.extend({ revision: 13, adapter: 'DS.FixtureAdapter' });kroofy

2 Answers

2
votes

It was due to a confusing combination of not defining a router initially (only for my example Zoo model) and not actually hitting that route (/#/zoos).

It turns out that Ember actually doesn't load fixtures into memory (only the model) until you execute a find on that model.

I can now hit the /#/zoos route and see the records loaded in the Ember Chrome extension.

0
votes

Your FIXTURES are loading just fine, I've created a working example out of the code you have provided: http://jsbin.com/odosoy/148/edit

There must be something else going on in your app that does not work, maybe in your ZoosRoute if you have one. Try to post more details on how you are loading the not working FIXTURES.

Hope it helps.