Pergunta

I have a following route definition in my ember-rails project. The file is /app/assets/javascripts/routes/applicationRoute.js.coffee and the code is as follows:

ChAdmin.ApplicationRoute = Ember.Route.extend (
   model: ()->
     store = @.get("store")
     store.push("tapahtuma",
       id: 1,
       nimi: "test1",
       paiva: "11.1.2012"
     )

)

This prevents the application template from rendering. Can anyone tell me why is that? I can see from embers inspector that the item has been pushed to store. If I do anything else except push items in the store the app template renders just fine.

There are no errors in javascript console and starting the app I get:

DEBUG: ------------------------------- ember.js?body=1:394
DEBUG: Ember.VERSION : 1.0.0 ember.js?body=1:394
DEBUG: Handlebars.VERSION : 1.0.0 ember.js?body=1:394
DEBUG: jQuery.VERSION : 1.10.2 ember.js?body=1:394
DEBUG: ------------------------------- ember.js?body=1:394
Ember Debugger Active

Any help would be much appreciated.

Foi útil?

Solução 2

Problem was an old version of ember-data. I ran "rails generate ember:install --head" and now the application template renders correctly.

Outras dicas

You should return the model from model()

App.IndexRoute = Ember.Route.extend({
  model: function(){
    var store = this.get('store');
    store.push("tapahtuma",
      {
         id: 1,
         nimi: "test1",
         paiva: "11.1.2012"
      }
     );
    // model is expected to return the object or 
    // a promise that resolve into the object
    return store.find('tapahtuma',1); 
  }
});

More details on the model() hook in the emberjs guide on routing.

JSBin example

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