Best way to share ActiveRecord models and data between different Rails Apps?

旧时模样 提交于 2019-12-03 12:04:49

问题


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)

回答1:


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.



来源:https://stackoverflow.com/questions/4308639/best-way-to-share-activerecord-models-and-data-between-different-rails-apps

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!