Reputation: 1335
I have a rails app that contains a StaticController with an index action:
class Private::StaticController < PrivateController
def index
end
end
routes.rb:
get 'static' => 'private/static#index'
I want to start an emberjs application in the corresponding view:
<%= javascript_include_tag 'ember_application' %>
<h1>Hello</h1>
<script type="text/x-handlebars">
<div>{{outlet}}</div>
</script>
For that I created a basic emberJS router:
PlatformUI.Router.map(function() {
this.route('test', { path: '/test' });
});
PlatformUI.Router.reopen({
rootURL: '/static/'
});
The template (in app/assets/javascripts/templates/test.handlebars) contains:
<script type="text/x-handlebars" data-template-name="test">
<h2>Something</h2>
</script>
When running the application, just the word 'Hello' is displayed on the page. The ember inspector (chrome plugin) says that emberjs is correctly loaded. Is there a problem with the routes? How can I debug this??
Gemfile:
gem 'ember-rails'
gem 'ember-source', '~> 1.9.1'
Update, I managed to get the transition logger to tell me I am in /test by changing the following:
PlatformUI.Router.map(function() {
//this.route('index', { path: '/' });
this.resource('test', { path: '/test' });
});
PlatformUI.Router.reopen({
location: 'history',
rootURL: '/static/'
});
The template is still not loading though. I see the script tag of the handlebar at the bottom of the page, it's not being used.
Upvotes: 0
Views: 246
Reputation: 1293
Do not include script tags in test.handlebars
template, content of this file should contain only handlebars template, i.e.
<h2>Something</h2>
Script tags are only needed if embedding templates into html directly.
Also, rails view should contain something like:
<head>
<!-- other standard head content -->
<%= javascript_include_tag 'ember_application' %>
</head>
<body>
</body>
Application template should be in application.handlebars
file, containing
<h1>Hello</h1>
<div>{{outlet}}</div>
Upvotes: 1