Charlie
Charlie

Reputation: 10307

Emberjs: findAll method missing on store

I'm trying to get emberjs working on rails and have been following this tutorial:

http://www.zhubert.com/blog/2012/04/28/ember-dot-js-and-rails-part-2/

When I try to run this command in the browser console:

var posts = App.store.findAll(App.Post)

I get an error because there is no findAll method on the store. I am using ember-data and am setting up the store like this:

App.store = DS.Store.extend({
  revision: 4,
  adapter: DS.RESTAdapter.create()
});

I've been using the ember rails generators but the whole thing seems pretty flakey, please help!

Upvotes: 1

Views: 1124

Answers (2)

Peter Wagenet
Peter Wagenet

Reputation: 5056

When using Ember's new router, it expects you to provide a class called App.Store. It then instantiates this as App.router.store. The store property is also automatically set on any controllers instantiated by the router.

Upvotes: 3

Charlie
Charlie

Reputation: 10307

Ok fixed the problem. The rails generator generated the wrong code.

This:

App.store = DS.Store.extend({
  revision: 4,
  adapter: DS.RESTAdapter.create()
});

should be:

App.store = DS.Store.create({
  revision: 4,
  adapter: DS.RESTAdapter.create()
});

Also, I might mention to anyone else who's having problems, the ember-rails generator also creates this:

App.ApplicationController = Ember.ObjectController.extend({

});

When it should be:

App.ApplicationController = Ember.Object.extend({

});

Upvotes: 0

Related Questions