Skip to content

Instantly share code, notes, and snippets.

@tansengming
Last active December 22, 2015 12:39
Show Gist options
  • Save tansengming/6474240 to your computer and use it in GitHub Desktop.
Save tansengming/6474240 to your computer and use it in GitHub Desktop.
notes on sharing data between Rails apps

Let's say you have a rails app and you want to build a separate admin app for it. There are at least two ways to go about this:

With a shared gem made of ActiveRecord models

The Good

  • It is relatively simple to set up. You split out all you AR models into a gem. Share the gem between the app and the admin app and voila.

The Bad

  • this breaks encapsulation. Meaning, that unless you plan carefully, admin will now need to know about things about the model that it shouldn't have to know. And vice versa.
  • because of the violation above, you'll also have to run CI against both apps when you update the shared gem
  • migrations will also have to be run on both apps.

Apps communicate via a HTTP API

The Good

The Bad

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment