12

I have several rails applications that will use the same core set of Models and data, for example:

  • Apps
  • Developers
  • Categories

Each app builds on top of this core data and uses it in different ways. For example, I might have something like this in another app:

  • Activity
  • Users
  • Apps (shared)
  • Developers (shared)
  • Categories (shared)

What is the best way to share the Models and data between them? The Apps, Developers and Category data will all be the same for every app so I would rather not have to duplicate the data in every app's database.

EDIT: I'm thinking through a couple of possible solutions:

  • Rails engines (would solve the duplicate Models in different apps problem, but not the shared data issue)
  • Using ActiveResource to access the core data (solves the shared data, but not the shared model issue)
markquezada
  • 8,444
  • 6
  • 45
  • 52
  • In your first possible solution, is sharing data a problem because each app are deployed to a different server? – lulalala Nov 02 '12 at 09:20
  • It's been a while since I asked this question, but from what I remember, yes that was the issue. Each rails app was on a different server. – markquezada Nov 03 '12 at 03:16

1 Answers1

4

I'm using a shared database to solve the shared data problem between heroku and a server on EC2 which does some background processing I can't do on heroku. In my case I'm using the same application, but really all I'm doing is using delayed_job on the EC2, so I'm only using the models from the app there. If I were going to use them in another application, I would probably go through the trouble of creating a gem to use between them.

Keith Gaddis
  • 4,113
  • 23
  • 20
  • Interesting... I actually need to do something very similar. (I'm using Heroku as well.) By shared database do you mean one _other_ than the Heroku one? In my case, I need to breakout the core stuff right away, but I hadn't thought about using a gem to do that. – markquezada Nov 30 '10 at 01:21
  • Yeah, I hosted the database with Amazon RDS, my app on heroku talks to that. About two weeks later heroku came out with their postgresql add-on (http://blog.heroku.com/archives/2010/11/10/heroku_postgresql/) which would have also worked for me. Probably would have preferred it actually, but c'est la vie. – Keith Gaddis Nov 30 '10 at 03:03