Pergunta

I have a Court.rb model (inheriting from Active Record) in my Rails app that I'm also using with ember-rails gem.

I created a Court model for it in Ember

 App.Court = DS.Model.extend({
    jurisdictionId: DS.attr('number'),
    name: DS.attr('string')
  });

There is a courts resource in the router

  App.Router.map(function() {
    this.resource("courts");
    this.resource("about");

  });

and, to retrieve the data, I created a courts route that calls findAll() on the Court model

App.CourtsRoute = Ember.Route.extend({
  model: function() {
    return App.Court.findAll();
  }

});

Ember's giving me a long error message for this, the final part of which says has no method 'findAll' . I also tried to use App.Court.find() and got the same error.

This is essentially what Ryan Bates did to retrieve data from the server in his Railscast on Ember He created an Entry model

Raffler.Entry = DS.Model.extend({
  name: DS.attr('string'),
  winner: DS.attr('boolean')
});

And also an Entries route that calls find on the model

 Raffler.EntriesRoute = Ember.Route.extend

  model:  -> Raffler.Entry.find()

Can you explain what I might be doing wrong to get this to work?

Foi útil?

Solução

You are probably running the latest version of Ember Data,

Try using:

return this.store.find('court'); instead of return App.Court.findAll();

Here's a jsfiddle showing a simple structure: http://jsfiddle.net/XUmTC/2/

For more information of the transition look here: https://github.com/emberjs/data/blob/master/TRANSITION.md

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top