Is the amber rail designed as an engine mount?

Ember and Rails newb are here with a serious question about everyone.

I am creating a project that uses ember-rails installation as shown here: https://github.com/dgeb/ember_data_example

However, to make things even more complex, the project must be packaged as a gem for inclusion in a larger application. To this end, I created a mountable engine containing a dummy project for testing.

The problem is that ember-rails and, in particular, pens cannot find patterns in their intended location. This prevents many functions from working properly.

In terms of moving the steering template directory, I found a solution here: How do I specify an alternative directory for my HandlebarsJS templates with ember-rails stone?

In conclusion, we say that we can specify the path to the templates in application.rb by setting the value config.handlebars.templates_root

However, I think this will cause a conflict if another ember-rails engine needs to be loaded into a larger application .. and this will require its own configuration parameter.

Does anyone have any experience with these settings and is there a way to make the ember namespace app enjoyable in a wider context?

By the way, these are rails 4, working with the latest reliefs on ruby ​​1.9.2.

+6
source share
4 answers

After doing a lot of research, it seems that Ember supports overriding the standard resolver: http://emberjs.com/api/classes/Ember.DefaultResolver.html

You can instruct him to search for templates in the application with names by following these instructions: https://github.com/emberjs/ember.js/pull/2354

Essentially, you can add a recognizer to your Ember.Application.create() : (to quote @lukemelia in the above stretch request)

 App1 = Ember.Application.create({ resolver: Ember.DefaultResolver.extend({ resolveTemplate: function(parsedName) { parsedName.fullNameWithoutType = "app1/" + parsedName.fullNameWithoutType; return this._super(parsedName); } }) }); 

This is similar to the part of ember rc5 at the time of writing.

+7
source

I just created an ember application inside the rails engine, and I had the same problems as you when you got rudder support. I could not get ember-rails to work inside the engine, so I looked at the source of ember-rails and I ended up just registering the tilt steering wheel in my engine directly. There are several configurations inside ember-rails to change the root template path: handlebars.templates_root. However, I was not successful in working inside the rail engine.

https://github.com/andrewmp1/spree_outlet

I'm still not very good at how to do integration tests with a dummy application. But his approach.

+1
source

This is an old ember application, as well as the rails engine . It uses ember-rails gem based on the gemfile entry. You can watch it. See how it is installed in the rail application: ember-cart-example . In addition, an online demo of the installed rail engine inside the rails application is presented here.

0
source

There is another solution for this: it’s not very effective, but it is simple, and it will work for this case (ember as an engine inside the rails application). Start by creating an initializer in your engine. There is no initializer directory in the engine configuration directory, but you can create one, and the initializers located in it will work.

 # path_to_engine/config/initializers/ember.rb YourEngine::Engine.config.handlebars.templates_root = "your_path/templates" 

Here you can also place any other configuration associated with the core associated with the engine.

0
source

Source: https://habr.com/ru/post/947554/


All Articles