How to migrate from ember-rails to ember-cli

TLDR; I’d love a post from Yakuda or anyone else on how to migrate my app to Ember CLI just like the cool kids on Ember Core say they have done.

I’m looking for guidance on migrating the Ember part of my Rails app to Ember CLI.

A decent guide to migrating across from ember-rails would be great as more and more of the community is assuming everyone is using ember-cli. I’d also appreciate anyones comments or links to relevant posts to get me started in the right direction.

Thanks!

Background

Ember CLI is now the preferred way to do Ember and the core team advised in November 2014 that “You should begin moving your app to Ember CLI as soon as possible”.

HackerNews asked: “While I’m using ember-cli for thick clients I’m using the ember-rails gem for sites which use a mix (mainly older projects). Has anyone figured out a good way to embed an ember-cli app inside rails?

“Yes, we do exactly this at Tilde and it works well. This sounds like a good blog post and possibly some released code that people can use.” said Yehuda.

1 Like

I agree a decent guide would be good. In the meantime I think just playing around with Ember CLI on a separate or experimental project is a good place to start. There will probably be innumerable little questions that come up as you try to get familiar with Ember CLI.

It would probably be helpful to create a reference app and show both before and after. Preferably in the same git repo. Perhaps the TODOs app would be a candidate. But I would love to see something moderately more complex.

Personally, I went from ember rails → Ember app kit rails → Ember CLI

A couple high level observations:

Get used to modules and node.js and NPM ecosystem. A lot different than the Globals (App.SomeController, App.Route, etc). Ember CLI puts a big emphasis on file organization and requires that you explicitly import related modules (including Ember and Ember Data).

Ember CLI will compile and build your output for you. In dev mode you can just run the ember project in isolation of your backend, make a change, livereload and go. When you are done you can run a build command and all the project will be output as concatenated and minified source code. Technically this code can be dropped into your assets folder. Or anywhere that is able to serve static HTML and Javascript. I personally use a rake task to dump the ember cli contents into the public folder of my rails project. But there are a lot of different ways to get from Ember CLI output to rails project.

Ember CLI supports live reloading, and you can proxy to your rails server as well. Ember CLI works really well when you think of your rails project as simply serving up API. You can launch your rails server on port 3000 and then have Ember CLI serve up the ember frontend code on port 4200 and then proxy over to the rails backend. This is all done through node and Express. Frontend and backend can in fact be separate projects or worked on in isolation.

ps it is Yehuda, not Yakuda. :smile:

Also, I believe the core team is working on a migration utility for this very problem. Something that will auto migrate from old App globals style to Ember CLI modules style.

Ping @terzicigor

Some places to start

http://reefpoints.dockyard.com/2014/05/07/building-an-ember-app-with-rails-part-1.html

This might be helpful too

https://github.com/rwz/ember-cli-rails

1 Like

@richiekhoo Did you manage to find any solution for this migration.I am actually working on a migration from ember-rails to ember-rails-cli.Please post a link, any tutorials or blog posts you came across if you have

Hi Charles, sadly I did not. The project I was working on is not currently under active development so we never implemented the upgrade. Sorry I can’t be of more help. Im obv interested in your journey also, would love you to share your progress, to help other lost ember-rails souls.

1 Like