Model not Found (Ember App Kit)


#1

I’m trying to use Ember App Kit with Ember Data (I’m using the latest of Both) using Fixtures - but for some reason I’m getting the following:

Assertion failed: No model was found for 'todo' [VM] ember.js (4005):415

Error while loading route: TypeError {} [VM] ember.js (4005):415

Uncaught TypeError: Cannot set property 'store' of undefined ember-data.js:2182

Application

import Resolver from 'resolver';
import registerComponents from 'appkit/utils/register_components';

var App = Ember.Application.extend({
  LOG_ACTIVE_GENERATION: true,
  LOG_MODULE_RESOLVER: true,
  LOG_TRANSITIONS: true,
  LOG_TRANSITIONS_INTERNAL: true,
  LOG_VIEW_LOOKUPS: true,
  modulePrefix: 'appkit', // TODO: loaded via config
  Resolver: Resolver
});

App.initializer({
  name: 'Register Components',
  initialize: function(container, application) {
    registerComponents(container);
  }
});

App.ApplicationAdapter = DS.FixtureAdapter.extend();

export default App;

Index Route

import Todo from 'appkit/models/Todo';

var IndexRoute = Ember.Route.extend({
  model: function() {
    return this.store.findAll('todo');
  }
});

export default IndexRoute;

Todo Model

var Todo = DS.Model.extend({
  'title': DS.attr('string'),
  'user': DS.attr('object'),
  'comment': DS.attr('string'),
  'mood': DS.attr('string')
});

Todo.FIXTURES = [{ 
    'title': 'Received Hardware!', 
    'user': { 'username': 'alvincrespo' }, 
    'comment': 'Finally received my hardware!',
    'mood': 'happy'
}, {
    'title': 'This is honorable.', 
    'user': { 'username': 'robwolf' }, 
    'comment': 'I regret it already.',
    'mood': 'happy'
}, {
    'title': 'I can\'t seem to speak', 
    'user': { 'username': 'catstark' }, 
    'comment': 'Wait a minute, why am I hear?',
    'mood': 'sad'
}, {
    'title': 'Attendance is poor.', 
    'user': { 'username': 'cerlan' }, 
    'comment': 'Kings landing seems pretty empty after the war.',
    'mood': 'neutral'
}];

export default Todo;

I’ve declared the DS.FixtureAdapter in app.js but for some reason its still not working? Any ideas?

Thanks!


#2

in EAK the global namespace should not be used to storing classes, instead you want to allow the resolver to resolve them by convention. in EAK that would be the module system/ file system.

FixtureAdapter in EAK (the todo mvc example)


How to get DS.RESTSerializer working in EAK?
#3

Hmm. I tried using the FixtureAdapter in application.js initially but for some reason it just wouldn’t pick up my fixtures. I’ve made a public repo called action-items here:

https://github.com/alvincrespo/action-items

I removed the App.ApplicationAdapter = DS.FixtureAdapter.extend(); from app.js.


#4

i have left some comments, after those changes everything works.

https://github.com/alvincrespo/action-items/commit/8724283e5f0d6c877a7cc688b167f9c5b3bafd33


#5

This topic was automatically closed after 3 days. New replies are no longer allowed.