【发布时间】:2014-02-27 16:12:00
【问题描述】:
我有一个相当基本的问题。
我正在学习将 Ember.js 与 Rails 后端一起使用。当在 HTML 文件中内联提到模板时,我可以让事情正常工作。
<script type="text/x-handlebars" id="index">
<div class="container-fluid">
<div class="row-fluid">
<div class="span3">
<table class='table'>
<thead>
<tr><th>Recent Posts</th></tr>
</thead>
{{#each item in model}}
<tr><td>
{{item.name}}
</td></tr>
{{/each}}
</table>
</div>
<div class="span9">
{{outlet}}
</div>
</div>
</div>
</script>
但是当我将这个 sn-p 移动到模板目录下的 .hbs 文件中,并在我的 application.js 文件中包含以下行时,
#= require_tree ./templates
他们因这个错误而失败。
Assertion failed: You specified the templateName cms2/index for <CMS.IndexView:ember229>, but it did not exist.
我尝试使用两个不同的 Rubygems 进行预编译,
gem 'handlebars_assets'
和
gem 'ember-rails'
根据我的阅读,这两个 gem 应该预编译所有 .hbs 文件,包括模板目录树应该可以解决这个问题。
我错过了什么?为什么这对我不起作用?
谢谢。
【问题讨论】:
标签: javascript ruby-on-rails ember.js handlebars.js