Question

DEBUG: ------------------------------- ember.js:3916
DEBUG: Ember      : 1.7.0-beta.1+canary.3d383376 ember.js:3916
DEBUG: Ember Data : 1.0.0-beta.7.f87cba88 ember.js:3916
DEBUG: Handlebars : 1.1.2 ember.js:3916
DEBUG: jQuery     : 1.10.2 ember.js:3916
DEBUG: ------------------------------- 

I'm starting a very simple application and trying out ember-data. I'm not sure if this is a bug or something I'm doing wrong. In my route and model function I have @store.find('post', 1) which works great. But if I try changing this to find all my records with @store.find('post') I get this error Error while loading route: posts No model was found for 'super' Error: No model was found for 'super' I don't know what super is and why would I need a super model? The error is coming from the function called modelFor: on line 9797 in ember.data.js. If I place a console.log(key) in this function I get the following output post, App.Post, super.

Below is the code I've got currently, its very basic:

App.Post

App.Post = DS.Model.extend
    title: DS.attr('string')
    description: DS.attr('string')

Router

App.Router.map () ->
   @resource 'posts'

Index Route

App.IndexRoute = Ember.Route.extend
    beforeModel: () ->
        @transitionTo 'posts',

Post Route

App.PostsRoute = Ember.Route.extend
    model: () ->
        @store.find('post')

Adapter/Serializer

App.ApplicationAdapter = DS.ActiveModelAdapter 

App.ApplicationSerializer = DS.ActiveModelSerializer

RESTAdapter

DS.RESTAdapter.reopen
    namespace: 'api/v1'

Hopefully someone can help me spot the error or bug.

Was it helpful?

Solution

It turns out that if your json response returns an empty array only you'll get this error. So for example - http://emberjs.jsbin.com/baras/1/edit. My json response should be returning post: [] and not just [] as this is not the correct format for ember data. Once I changed the json to return post: [] everything worked as normal.

Guides: http://emberjs.com/guides/models/the-rest-adapter/#toc_json-root

Good read: http://jsonapi.org/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top