2 つの単純なモデル (ember-model) を持つ単純な EmberJS アプリケーションがあります。アカウントとアイテム。アカウントには多くのアイテムがあります。
したがって、アプリケーション内のリンクを使用して #/accounts/1/items に移動すると、完全に正常に動作します。ただし、 #/accounts/1/items を直接リロードすると、エラーが発生します。
Assertion failed: The value that #each loops over must be an Array. You passed <App.Account:ember335> (wrapped in (generated items controller)) ember.js?body=1:382
Uncaught TypeError: Object [object Object] has no method 'addArrayObserver' ember.js?body=1:19476
Assertion failed: Emptying a view in the inBuffer state is not allowed and should not happen under normal circumstances. Most likely there is a bug in your application. This may be due to excessive property change notifications. ember.js?body=1:382
これは私のアプリがどのように見えるかです:
App.Router.map ()->
@resource 'accounts', ->
@resource 'account', path: ':account_id', ->
@resource 'items'
App.AccountRoute = Ember.Route.extend
model: (params) ->
App.Account.find(params.account_id)
App.ItemsRoute = Ember.Route.extend
model: ->
@.modelFor('account').get('items')
App.Account = Ember.Model.extend
name: Ember.attr('string')
item_ids: Ember.attr(),
items: (->
App.Items.find(@.get('comment_ids'))
).property('comment_ids')
App.Item = Ember.Model.extend
name: Ember.attr('string')
コントローラは標準 (空) です。
JS コンソールでは、次のような呼び出しは正常に機能し、エラーがスローされた (何もレンダリングされない) 後でも正しい結果を返します。
App.Account.find(1).get('items')
なぜこれが起こっているのかわかりません。コードは非常に単純なので、手がかりがないのは本当に面倒です。誰にもアイデアがありますか?