私は、非常に単純な問題のように見える問題に対する答えまたは修正を見つけようとして立ち往生しています。
最近RailsAPIアプリを始めました。私は EmberJS をいじって、ここにある最近のチュートリアルに従うことにしました
アプリのインデックス ページに移動すると、空白の画面しか表示されず、テンプレートがレンダリングされません。何らかの理由で Ember が私のテンプレートを見つけられないようです。
コンソールに表示される内容は次のとおりです。
DEBUG: ------------------------------- ember-1.0.0.js?body=1:394
DEBUG: Ember.VERSION : 1.0.0 ember-1.0.0.js?body=1:394
DEBUG: Handlebars.VERSION : 1.0.0 ember-1.0.0.js?body=1:394
DEBUG: jQuery.VERSION : 1.9.1 ember-1.0.0.js?body=1:394
DEBUG: ------------------------------- ember-1.0.0.js?body=1:394
generated -> route:application Object {fullName: "route:application"} ember-1.0.0.js?body=1:394
generated -> route:index Object {fullName: "route:index"} ember-1.0.0.js?body=1:394
generated -> controller:application Object {fullName: "controller:application"} ember-1.0.0.js?body=1:394
Could not find "application" template or view. Nothing will be rendered Object {fullName: "template:application"} ember-1.0.0.js?body=1:394
generated -> controller:index Object {fullName: "controller:index"} ember-1.0.0.js?body=1:394
Could not find "index" template or view. Nothing will be rendered Object {fullName: "template:index"} ember-1.0.0.js?body=1:394
Transitioned into 'index' ember-1.0.0.js?body=1:394
=> Ember.TEMPLATES
# Object {}
ご覧のとおり、Ember.TEMPLATES は空です。私の現在のアプリ構造は次のようになります
Dojo
- app
- assets
- javascripts
- templates
- application.hbs
- index.hbs
- application.js.coffee
- router.js.coffee
- controllers
など、随時更新していきます。基本的なRailsアプリです。
関連するファイルは次のようになります。
アプリケーション.js.コーヒー
#= require jquery-1.9.1
#= require handlebars-1.0.0
#= require ember-1.0.0
#= require ember-data
#= require_self
#= require router
#= require_tree ./models
#= require_tree ./controllers
#= require_tree ./views
#= require_tree ./templates
#= require_tree ./routes
window.AppDojoApi = Ember.Application.create
LOG_TRANSITIONS: true
LOG_BINDINGS: true
LOG_ACTIVE_GENERATION: true
LOG_VIEW_LOOKUPS: true
console.log Ember.TEMPLATES
テンプレート/application.hbs
<div class='container'>
<div class='content'>
<div class='row'>
<div class='span12'>
<div class='page-header'></div>
{{outlet}}
</div>
</div>
</div>
</div>
</div>
テンプレート/index.hbs
<h1> Hello World </h1>
必要なすべてのファイル (ember、ハンドルバー、jQuery) は、コンソールにエラーが表示されず、生成された HTML にあるため、正しくレンダリングされています。
handlebar_assets
のアセットをコンパイルするためにgem を使用していますAssetsPipeline
が、テンプレートは正しく生成されています。
ember がテンプレートを見つけられないのはなぜですか? 助けてくれてありがとう
更新https://github.com/AppDojo/AppDojo-API/tree/ember-railsapiに興味がある人は、ソース コードをご覧ください。
解決
HandlebarsAssets::Config.ember = true
テンプレートの適切なテンプレート ストレージを に設定しEmber.TEMPLATES
ます。s
ハンドルバーから 欠品していました...