1
votes

I'm using ember-cli and trying to make some sense of the structure of the app and how it is all wired together. There are some differences in the main Ember guide docs and what I'm seeing in the ember-cli generated project. I understand the API's are moving fast so I just need to be pointed in the right direction.

In router.js I have the following:

Router.map(function() {
  this.route('domains', {path: "/domains" });
});

Then I have models/domain.js

import DS from 'ember-data';

var Domain = DS.Model.extend({
    name: DS.attr('string')
});

Domain.reopenClass({
  FIXTURES: [
    { id: 1, name: 'User'},
    { id: 2, name: 'Address'}
  ]
});

export default Domain;

And I have routes/domains.js

import Ember from 'ember';

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

And finally ( I think ), I have templates/domains.hbs

<h1>Domains</h1>

{{#each}}
  <p>{{name}}</p>
{{/each}}

Only the header is being rendered when I visit the http://localhost:4200/domains url. I'm using the ember chrome extension and I don't see any data coming back in the request. I'm not sure if it is a naming convention issue or what I'm doing wrong so any help is appreciated.

2

2 Answers

2
votes

all just returns records that have already been found in the store. find will issue a request (in this case hitting the fixtures) and populate the store, and also return all of the records in the store.

this.store.find('domain');
1
votes

The problem ended up being 2-fold. Kingpin2K was right in that I needed to use find instead of all. I also had to change the adapter to the following in adapters/application.js:

export default DS.FixtureAdapter.extend();