Lately I’ve been playing with Ember.js and I have
really grown to love it. I get the same “AHA!” feeling I got building my
first Rails app 7 years ago. Let’s see how to
build a simple
CRUD app
using the RailsAPI as the
backend. We’re going to build a new app and deploy to Heroku.

Part 1 - Getting Set Up

gem install rails-api
rails-api new ember-app
cd ember-app

Similar to the rails command RailsAPI comes with a rails-api
command which under the hood is just using the normal rails CLI code
but overriding some of the templates generated. Out of the box
RailsAPI won’t generate the asset pipeline directories
as there is still some
debate if it will use
Sprockets,
Rake-Pipeline or some
other solution. In this example we’re going to use Sprockets as it will
save us a lot of time. RailsAPI is bundled with
ActionPack
which has Sprockets as a dependency. All we need to do is add in the
directories

ActiveModelSerializers is a project that is written by the Ember core team which will normalize the JSON output for models in a Rails app.

HandlebarsAssets will allow the AssetPipeline to compile Handlebars templates which is required for Ember. There is the Ember-Rails gem which will also do this but I have found HandlebarsAssets to be a leaner solution.

After this, don’t forget to run bundle install from the command line to pick up the gems we just added.