reknirt
reknirt

Reputation: 2254

Switched over js object to Ember Data model using Fixture Adapter and keep getting "Cannot call method 'findAll' of undefined" error

I'm working through the Code School Ember.js course and I have a Product model that is being loaded via the Fixture Adapter. My issue is that whenever I click on the 'products' link, linking to '/products' I get an error reading:

Error while loading route: TypeError: Cannot call method 'findAll' of undefined

My ProductsRoute looks like:

App.ProductsRoute = Ember.Route.extend({
    model: function() {
        return this.store.findAll('product');
    }
});

And the route fails to render.

Before I started using Ember Data and the Fixture adapter I was just using a js array of objects and calling it in the model: property of my Route object, which worked fine.

Here's my jsbin, minus the Ember Data Library:

http://emberjs.jsbin.com/zicofeku/1/edit

And here's an image of my console error:

enter image description here

Upvotes: 2

Views: 248

Answers (1)

Martin Stannard
Martin Stannard

Reputation: 811

I assume you're trying to get all Product records? In this case just use find with no parameters. See the docs for details.

Your code should look like:

App.ProductsRoute = Ember.Route.extend({
    model: function() {
        return this.store.find('product');
    }
});

Upvotes: 1

Related Questions