SuperUberDuper
SuperUberDuper

Reputation: 9623

Ember error: No model was found

When I visit a route that has a model hook:

export default Ember.Route.extend({
  model: function () {
    return this.store.find("account_type");
  }
});

I get this error:

Error while processing route: register No model was found for 'account_type' Error: No model was found for 'account_type'

I have a file in models called account_type.js :

import DS from 'ember-data';

export default  DS.Model.extend({
  type: DS.attr('string')
});

mock route:

  app.use('/api/account_type', accountTypesRouter);

Any ideas?

Upvotes: 1

Views: 1919

Answers (1)

Peter Brown
Peter Brown

Reputation: 51697

It looks like you're using ember-cli, and if that's the case, the standard separator convention for names is dashes, not underscores. I think if you change the route to look for 'account-type' instead, that should fix it.

export default Ember.Route.extend({
  model: function () {
    return this.store.find("account-type");
  }
});

If that doesn't work, you might need to change the file name to account-type.js too.

Edit

It looks like dasherized file names are required.

Upvotes: 1

Related Questions