Ember.js集成到Rails 3.2.8

时间:2012-10-05 00:43:37

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

我是ember.js的新手。我正在尝试使用ember-rails gem将ember.js与Rails集成。但是,当我启动服务器并打开浏览器控制台时,我会收到以下错误:

Uncaught Error: assertion failed: Ember Views require jQuery 1.7 :3000/assets/ember.js?body=1:43
Uncaught TypeError: Cannot call method 'extend' of undefined :3000/assets/ember-data.js?body=1:141
Uncaught ReferenceError: Blog is not defined :3000/assets/store.js?body=1:1
Uncaught ReferenceError: Blog is not defined :3000/assets/controllers/application_controller.js?body=1:1
Uncaught ReferenceError: Blog is not defined :3000/assets/views/application_view.js?body=1:1
Uncaught TypeError: Cannot call method 'template' of undefined :3000/assets/templates/application.js?body=1:1
Uncaught ReferenceError: Blog is not defined :3000/assets/routes/app_router.js?body=1:1
Uncaught ReferenceError: Blog is not defined :3000/assets/blog.js?body=1:10
Uncaught TypeError: Cannot call method 'create' of undefined ember.js:10183
Uncaught ReferenceError: Blog is not defined 

如何解决?或者如何通过手动将ember.js集成到rails。

感谢您的建议。

1 个答案:

答案 0 :(得分:2)

以下是ember-rails的问题(https://github.com/emberjs/ember-rails/issues/88)

要强制jquery为1.7,可以使用jquery-rails gem的1.0.19版本。因此,将您的Gemfile更改为:

gem "jquery-rails", "1.0.19"

你会被设定。

作为替代方案,您可以遵循GH问题中的建议,

var ENV = {'FORCE_JQUERY': true};

在加载ember.js之前覆盖任何版本的jquery的需求检查。 (我没有测试过这个)。