I’m trying to setup Ember.js with Rails 3.1 and I’m getting the following error in the Firebug console:
uncaught exception: Error: <(subclass of App.ListOrdersView):ember201> - Unable to find template "app/templates/orders/list".
I followed this guide. Here is my manifest file, which correctly loads all the js:
//= require jquery
//= require jquery_ujs
//= require jquery-ui
//= require vendor/ember
//= require vendor/ember-rest
//= require_tree ./../lib
//= require app/app
//= require_tree ./../app/models
//= require_tree ./../app/controllers
//= require_tree ./../app/views
//= require_tree ./../app/helpers
//= require_tree ./../app/templates
//= require_self
This is the handlebar template app/templates/order/list.handlebars:
<table>
<thead>
<tr>
<th>ID</th>
<th>Name</th>
</tr>
</thead>
<tbody>
{{#each orders}}
{{view App.ShowOrderView orderBinding="this"}}
{{/each}}
</tbody>
</table>
And the Rails view file app/views/orders/index.html.haml
%script{:type => "text/x-handlebars"}
= hb 'view App.ListOrdersView'
:javascript
$(function() {
App.ordersController.loadAll(#{@orders.to_json.html_safe});
});
Finally the gems for Ember.js, in Gemfile:
# Ember
gem 'ember-rails'
gem 'hamlbars', :git => "https://github.com/jamesotron/hamlbars.git"
gem 'rasputin'
You should probably use either
ember-railsorrasputin, but using both gems together might lead to unpredictable behavior. Since they both attempt to register and precompile your handlebars templates, they are redundant in purpose but their usage differs.If you look at the readme for
rasputin, you’ll see that templates get registered withouttemplatesin their path. Therefore, if you want to use this gem, you’ll need to declare your template asapp/orders/listinstead ofapp/templates/orders/listinApp.ListOrdersView.