I've been stuck trying to find an answer or a fix to what seems a very simple issue.
I have recently started RailsAPI app. I decided to play around with EmberJS and follow a recent tutorial found here
When I go to the index page of my app, all I see is a blank screen and my templates won't render. It seems that Ember is not able to find my templates for some reason.
Here's what I see in the console:
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 {}
As you can see, the Ember.TEMPLATES is empty. My current app structure looks like this
Dojo
- app
- assets
- javascripts
- templates
- application.hbs
- index.hbs
- application.js.coffee
- router.js.coffee
- controllers
And so on, I will update as needed. Its pretty much a basic Rails app.
Here's how my relevant files look like:
application.js.coffee
#= 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
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>
templates/index.hbs
<h1> Hello World </h1>
All of the necessary files (ember, handlebars, jQuery) are being rendered correctly because I don't see any errors in the console and they are in the HTML generated.
I'm using the gem handlebar_assets
to compile the assets for the AssetsPipeline
and the templates are being generated correctly.
Why wouldn't ember be able to find the templates? Thanks for the help
UPDATE Here's the source code if anyone is interested in taking a look at it https://github.com/AppDojo/AppDojo-API/tree/ember-railsapi
SOLUTION
Setting HandlebarsAssets::Config.ember = true
set the right template storage for the templates to Ember.TEMPLATES
. I was missing an s
from Handlebars...