Allow Rails to share Ember CLI project structure?


#1

Is there any big red flags if one were to setup a Rails and Ember CLI app to share the same directory structure? For a tightly integrated app with a Ember.js front-end and a Rails REST back-end application it would have the benefit of keeping the server side and front end files together.

For example, an app with a single ActiveRecord model might have the following files in the /models directory:

/app/models/song.rb
/app/models/song.js

There are some common top-level directories: app, config, public and vendor. However, within those directories there doesn’t seem to be any name collisions. Upon deployment the Ember CLI app would be generated in /public as normal.

I haven’t tried it yet. Thoughts?


#2

You’ll probably find plenty of folks that disagree with me, but I don’t think there’s a net upside to combining your front-end and back-end codebases. At a minimum, if the build tooling doesn’t freak out today, there’s no guarantee that it won’t tomorrow. From a best practices standpoint, you have what are essentially two different apps sharing a repo, branches, pull requests, etc. If you have some reason to change your back-end (or front-end) in the future, you have to extract all the other other code instead of just pointing it somewhere else. I wouldn’t do it, and I would go a little cross-eyed if I saw it in the wild. YMMV.


#3

@palmergs Ember App Kit Rails took that approach originally. I think long term it was decided that it was not worth the effort.

There are a lot a reasons to keep the projects separate.

Currently I have a rails app that has been in production for over a year. What we do is have an ember folder inside our rails folder. So everything can be part of the same repo. But we have a rake task that builds the app and take the production build and puts it in the rails public folder.

Other people use https://github.com/ember-cli/ember-cli-deploy

The advantage of having two separate apps is that it is possible to separate the deploys. You can easily push the rails app/api at different intervals. And the ember frontend app can be deployed with out a restart of rails app. Or even sync’d to a CDN.

But I understand the appeal of having ruby models and ember models side by side.