tspore
tspore

Reputation: 1349

Running Ember only on subroute

On my ember application, I don't want it hooked into the root url(s) instead on a subpath controller. How do I do this? For example: / <- home page & /contact <- static (non JS app - Just render though Rails) But I want /my_awesome_JS_app && /my_awesome_js_app/1 to have ember running on that.

The final goal will be to have when a request comes in to /my_awesome_app/1234 -> It hits the rails application Which checks server side for browser compatibility. After that if its compatible it will load in the ember application -

So right now with Ember hitting - root - and rails rendering off and ignoring the /#/ and only showing - / of the hash. I'm a bit stumped and what would be a good solution for this issue. This would be a part 2 to my original question - ember hash urls in google

Upvotes: 0

Views: 179

Answers (1)

Mik
Mik

Reputation: 4187

You can require code, that relates to Ember, only in your /my_awesome_js_app urls. To do this, you can place a specific javascript_include_tag 'ember_app' into view, which loads in this url. And in file app/assets/javascripts/ember_app.js you should have initialization code for ember. For example, in my case this file looks like:

#= require handlebars
#= require ember
#= require ember-data
#= require_self
#= require store
#= require_tree ./models
#= require_tree ./controllers
#= require_tree ./views
#= require_tree ./helpers
#= require_tree ./templates
#= require_tree ./routes

window.App = Ember.Application.create
  rootElement: '#ember'

Don't forget, that you should not require this file in application.js (be aware of require_tree .).

Upvotes: 1

Related Questions