Rails, ember cli and ember-data

On our first ember project we had no control over the API and so we have a bad experience with ember-data (a lot of monkey-patching). We also started before ember-cli was big, so we have no experience with that, especially with a rails app.

On our newest project we write the Rails app (API) on our own and want to use ember. What would you suggest? Should we use ember-cli, should we use ember-data (does it work good with active model serializer?) How to deal with the asset pipeline?

Cheers Nicolas

1 Like

I wouldn’t call myself a rails developer, but I know that ember+ember-cli+ember-data are all designed to work with any backend through a JSON api.

Checkout this google search: ember-rails or ember-cli - Google Search

Full of blog articles on Ember-CLI and Rails, and notably a project called “ember-cli-rails” that specifically deals with making sure ember+ember-data+ember-cli+rails can all work smoothly together out of the box.

Please let us know how this works out, I’m definitely curious about ember-cli-rails…

One option (and probably preferred), to build your Ember app in separate repo (folder), independently, and build your Rails API without views and asset pipeline. You can use rails-api gem, so you will have a lightweight rails. You have to launch your ember server and rails s separately.

Other option to insert the ember app inside your assets pipeline, but you always have to deploy the whole rails app, however you maybe just changed something in your frontend client.

How to deal with the asset pipeline?

If you’re going Ember-only on the front-end, you can probably ditch the asset pipeline as a whole, in favor of Ember CLI. It can compile your assets and even deploy your whole front-end onto S3 (or anywhere else). Check out GitHub - ember-cli-deploy/ember-cli-deploy: A deployment pipeline for Ember CLI apps for a good deployment strategy.

As @zoltan mentioned, I prefer to keep my Ember application in one repository and my Rails application in another. With Rails 5, I believe they’re making it easier to build APIs with Rails that will remove all the front-end cruft for you.

Lastly, take into consideration that Ember 2.0 will be designed to work with the JSONAPI spec out of the box. My bet is that you’ll have the easiest time working with Ember Data going forward if you adhere to it as well. However, the specs are still a work in progress and is expected to reach 1.0 on May 21.

I’ve had pretty good luck using ember-cli-rails to embed an ember CLI app into an already-existing rails app. You can even have multiple ember apps within in the same rails app if you want.