Ember & Rails newb here with a serious question about both.
I'm building a project that leverages the ember-rails setup as exemplified here: https://github.com/dgeb/ember_data_example
However, to make things even more complicated, the project is intended to be packaged as a gem, for inclusion in a larger app. To that end I've created a mountable engine, containing a dummy project for testing.
Problem is, ember-rails, and and specifically handlebars cannot find the templates in their intended location. This prevents a lot of the functionality from working properly.
In terms of moving the handlebars template directory, I have found a solution here: How can I specify an alternative directory for my HandlebarsJS templates with the ember-rails gem?
In summary it states we can specify the path to the templates in application.rb by setting the value of config.handlebars.templates_root
However, I think this will cause a conflict should another ember-rails engine need to be loaded into a larger app.. and that one will need its own configuration setting.
Does anyone have experience with these setups, and is there any way to make a namespaced ember app play nice within a larger context?
By the way, this is rails 4 running the latest ember-rails on ruby 1.9.2.
After doing a lot of research, it seems that Ember supports overriding the Default Resolver: http://emberjs.com/api/classes/Ember.DefaultResolver.html
You can instruct it to look for templates in your namespaced application by following the instructions here: https://github.com/emberjs/ember.js/pull/2354
In essence, a resolver can be added to your Ember.Application.create()
: (to quote @lukemelia in the aforementioned pull request)
App1 = Ember.Application.create({
resolver: Ember.DefaultResolver.extend({
resolveTemplate: function(parsedName) {
parsedName.fullNameWithoutType = "app1/" + parsedName.fullNameWithoutType;
return this._super(parsedName);
}
})
});
This seems to be a part of ember rc5 at the time of writing.
I just created an ember app inside a rails engine and I had the same issues as you did w/ getting handlebars support. I couldn't get ember-rails to work inside an engine so I looked at ember-rails source and I ended up just registering handlebars w/ tilt in my engine directly. There are some configurations inside ember-rails to change the root template path: handlebars.templates_root. However I didn't have success in getting that to work inside a rails engine.
https://github.com/andrewmp1/spree_outlet
I still haven't really grokked how I would do integration tests w/ the dummy app. But its coming along.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With