按下浏览器的后退和前进按钮时出现Ember抛出错误

时间:2014-01-26 09:03:33

标签: ruby-on-rails ember.js ember-rails

我有以下路线:

Redb.Router.map ()->
  @resource "forms", ->
    @route "new"
    @route  "show", path: "/:form_id"

我有关联的模板和控制器。

使用link-to帮助程序生成的链接,一切正常,但是,例如当我#/forms/1并回到#/forms时,它会出现以下错误:

Assertion failed: The initializer 'store' has already been registered
Assertion failed: The initializer 'dataAdapter' has already been registered
Assertion failed: The initializer 'injectStore' has already been registered 

然后,当我按下前进按钮时,我得到:

Error while loading route: TypeError: Cannot set property 'store' of undefined
    at DS.Store.Ember.Object.extend.modelFor (http://localhost:3000/assets/ember-data.js?body=1:2726:19)
    at DS.Store.Ember.Object.extend.find (http://localhost:3000/assets/ember-data.js?body=1:1730:17)
    at Ember.Route.Ember.Object.extend.findModel (http://localhost:3000/assets/ember.js?body=1:34817:23)
    at Ember.Route.Ember.Object.extend.model (http://localhost:3000/assets/ember.js?body=1:34806:17)
    at getModel (http://localhost:3000/assets/ember.js?body=1:33269:45)
    at model (http://localhost:3000/assets/ember.js?body=1:33197:17)
    at invokeCallback (http://localhost:3000/assets/ember.js?body=1:9428:19)
    at publish (http://localhost:3000/assets/ember.js?body=1:9098:9)
    at Promise.publishFulfillment (http://localhost:3000/assets/ember.js?body=1:9518:7)
    at Object.DeferredActionQueues.flush (http://localhost:3000/assets/ember.js?body=1:5651:24)

Error while loading route: TypeError: Cannot set property 'store' of undefined
    at DS.Store.Ember.Object.extend.modelFor (http://localhost:3000/assets/ember-data.js?body=1:2726:19)
    at DS.Store.Ember.Object.extend.find (http://localhost:3000/assets/ember-data.js?body=1:1730:17)
    at Ember.Route.Ember.Object.extend.findModel (http://localhost:3000/assets/ember.js?body=1:34817:23)
    at Ember.Route.Ember.Object.extend.model (http://localhost:3000/assets/ember.js?body=1:34806:17)
    at getModel (http://localhost:3000/assets/ember.js?body=1:33269:45)
    at model (http://localhost:3000/assets/ember.js?body=1:33197:17)
    at invokeCallback (http://localhost:3000/assets/ember.js?body=1:9428:19)
    at publish (http://localhost:3000/assets/ember.js?body=1:9098:9)
    at Promise.publishFulfillment (http://localhost:3000/assets/ember.js?body=1:9518:7)

我是Ember的新手,我正在努力学习它。任何人都可以帮我这个吗?

1 个答案:

答案 0 :(得分:3)

如上所述[{3}},问题出在turbolinks,当点击后退和前进按钮时,turbolinks会导致奇怪的效果。

删除turbolinks可以解决问题。