1
votes
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.

1
What's the data that comes back from your server when you call find('post'), will you show your adapter/serializer as wellKingpin2k
Its not even calling the server as it errors first with the error I've mentioned in my question. I've only included my adapter/serializer as follows: App.ApplicationAdapter = DS.ActiveModelAdapter and App.ApplicationSerializer = DS.ActiveModelSerializerPeter
okay, will you show your router as wellKingpin2k
Thanks. The router is in my question. Post Route. Is that what your asking for?Peter
It generally looks like this App.Router.map(function() { // put your routes here });, here's an example emberjs.jsbin.com/OxIDiVU/151/editKingpin2k

1 Answers

4
votes

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/