我正在將我的第一個Ember
應用程序集成到Rails項目中。我已經加入了ember-cli-rails
寶石並運行初始化,使我有一個config/initializers/ember.rb
文件看起來像這樣:如何在Rails中修復此Ember CLI錯誤?
EmberCLI.configure do |c|
c.app :products, path: 'products'
end
我灰燼的應用是在我的Rails應用程序的根,被稱爲products
。除了現在生成默認的Ember應用外,我什麼也沒做。
我在Rails中爲ProductsController
創建了一個特定的佈局。它是app/views/products.html.erb
。我已經添加了以下行:
<%= include_ember_script_tags :products %>
<%= include_ember_stylesheet_tags :products %>
我還編輯了router.js
文件爲灰燼應用,因爲我不是服了在根URL灰燼應用:
var Router = Ember.Router.extend({
rootURL: config.baseURL, // added this line
location: config.locationType
});
最後我改變config/environments.js
在我的灰燼應用
var ENV = {
modulePrefix: 'products',
environment: environment,
baseURL: '/products', // changed from '/' to '/products'
locationType: 'auto',
EmberENV: {
FEATURES: {
// Here you can enable experimental features on an ember canary build
// e.g. 'with-controller': true
}
},
索引頁面出現罰款,此控制器。而且它試圖加載灰燼文件,但是我收到一個錯誤:
Uncaught Error: Assertion Failed: rootURL must end with a trailing forward slash e.g. "/app/"
爲ember-cli-rails
的說明不包括尾隨斜線。
而且如果我不加斜槓,我得到:
Uncaught Error: Assertion Failed: Path /products does not start with the provided rootURL /products/
我意識到我可能失去了一些東西在我這裏第一灰燼應用非常基本的。非常感謝您提供的任何幫助。
我也因爲了解到,這是包括Rails應用程序內的灰燼應用程序的老式的方法。 – AKWF
不再適用於Rails 5! – thesubroot