2014-12-22 42 views
0

我的所有版本的特性「發現」:餘燼未初始化存儲在正確:無法讀取未定義

Ember: 1.9.0 
Handlebars: 2.0.0 
jQuery: 2.1.3 
Ember Data: 1.0.0-beta.12 

所有我想要做的就是一個簡單的餘燼數據store.find()電話,一切似乎是可怕的打算錯誤。 它也變得更加怪異。如果我將this.store.find(...)換成get()調用,而改爲this.get('store').find(...),我會得到完全不同的錯誤。

這裏我只this.store.find(...)得到的錯誤:

Error while processing route: budget Cannot read property 'find' of undefined TypeError: Cannot read property 'find' of undefined 
at Application.BudgetRoute.Ember.Route.extend.model (http://localhost/javascript/app/routes/budget.route.js:9:24) 
at EmberObject.extend.deserialize (http://localhost/javascript/bower_components/ember/ember.js:24849:21) 
at applyHook (http://localhost/javascript/bower_components/ember/ember.js:47575:30) 
at Object.HandlerInfo.runSharedModelHook (http://localhost/javascript/bower_components/ember/ember.js:45596:22) 
at Object.subclass.getModel (http://localhost/javascript/bower_components/ember/ember.js:45822:21) 
at __exports__.bind (http://localhost/javascript/bower_components/ember/ember.js:47449:19) 
at tryCatch (http://localhost/javascript/bower_components/ember/ember.js:47898:16) 
at invokeCallback (http://localhost/javascript/bower_components/ember/ember.js:47910:17) 
at publish (http://localhost/javascript/bower_components/ember/ember.js:47881:11) 
at http://localhost/javascript/bower_components/ember/ember.js:29453:9 

this.store這裏不確定的。

這裏是我與this.get('store').find(...)得到錯誤:

Error while processing route: budget Assertion Failed: Budget has no method `find`. Error: Assertion Failed: Budget has no method `find`. 
    at new Error (native) 
    at Error.EmberError (http://localhost/javascript/bower_components/ember/ember.js:13740:23) 
    at Object.Ember.assert (http://localhost/javascript/bower_components/ember/ember.js:3902:15) 
    at Object.EmberObject.extend.store.computed.find (http://localhost/javascript/bower_components/ember/ember.js:24892:19) 
    at Application.BudgetRoute.Ember.Route.extend.model (http://localhost/javascript/app/routes/budget.route.js:9:32) 
    at EmberObject.extend.deserialize (http://localhost/javascript/bower_components/ember/ember.js:24849:21) 
    at applyHook (http://localhost/javascript/bower_components/ember/ember.js:47575:30) 
    at Object.HandlerInfo.runSharedModelHook (http://localhost/javascript/bower_components/ember/ember.js:45596:22) 
    at Object.subclass.getModel (http://localhost/javascript/bower_components/ember/ember.js:45822:21) 
    at __exports__.bind (http://localhost/javascript/bower_components/ember/ember.js:47449:19) 

這次發現this.store,但預算模式上有沒有find()方法(和在互聯網上任何地方都存在指令說應該有......)

budget.route.js:

define([ 
    'ember', 
    'application', 
    'controllers/budget.controller', 
    'views/budget.view' 
], function(Ember, Application) { 
    Application.BudgetRoute = Ember.Route.extend({ 
    model: function(params) { 
     return this.store.find('budget', params.budget_key); 
    } 
    }); 

    return Application.BudgetRoute; 
}); 

我的預算模型:

define([ 
    'ember-data', 
    'application' 
], function(DS, Application) { 
    Application.Budget = DS.Model.extend({ 
    budget_key: DS.attr(), 
    user: DS.attr(), 
    title: DS.attr(), 
    description: DS.attr(), 
    picture: DS.attr(), 
    order: DS.attr(), 
    created: DS.attr() 
    }); 

    return Application.Budget; 
}); 

我ApplicationAdapter:

define([ 
    'ember-data', 
    'application', 
    'models/budget' 
], function(DS, Application) { 
    Application.ApplicationAdapter = DS.RESTAdapter.extend({ 
    namespace: 'api' 
    }); 

    return Application.ApplicationAdapter; 
}); 

我還使用deferReadiness()advanceReadiness()如果使這裏的任何區別...

回答

0

我與1.9.0看到這一點。似乎該商店根本就沒有設置,MyApp.__container__.lookup("store:main")undefined。我花了一些時間試圖追蹤這個,但我認爲這可能是一個重大的兔子洞,我沒有找到任何答案。

1.10.0-beta.1似乎正在工作。我知道這不是真正的答案,但我希望在這種情況下比沒有好。

+0

我試圖降級到Ember-Data beta.1,它沒有幫助。你指的是哪種版本的Ember和Ember-Data? –

+0

這是我得到的最終工作,但我不認爲這個問題是與燼數據--- Ember:1.9.0 Ember數據:1.0.0-beta.12 把手:2.0。 0 jQuery:1.11.2 –

+0

嗯,這些都是我的確切版本。雖然沒有運氣。你能在哪裏做這項工作?它在線嗎? –