Using Rails ERB and Ember-CLI together

We are thinking of migrating a Rails/Ember app to use Ember-CLI. Before we attempt that I have some questions.

We use i18n-js which allows us to define translations in Ruby (YAML actually,) and have those appear in Javascript on the front end. Can this continue to work with ember-cli? This requires Rails ERB to work and we have an en.js.erb file for example.

We also compile Sass files at runtime to generate customized CSS. This is also ERB based where we have say colors.scss.erb which takes dynamic settings from the database when generating css. Can this work with ember-cli?

Ideally, we would like to use both the Rails asset pipeline with ember-cli with some files served by each. How can this be made to work?

Thanks for any info.

Hey @sudrao,

There is growing momentum behind the ember-cli-rails project which allows running Ember CLI in the context of Rails. The only limitation I know of currently is that it relies on Rails to serve all static assets (e.g. fonts, css etc.) but from what it sounds like you have these in Rails already.

Here is a good, recent tutorial on Setting up Ember.js (ember-cli) with Rails.

In terms of the erb processing for both JS and CSS/Sass, you can continue to use Rails to generate those as normal, and then make sure to include links in the template/layout that loads the Ember CLI app.

I hope this gives you some pointers.

1 Like