简体   繁体   English

在不同的Rails应用程序之间共享ActiveRecord模型和数据的最佳方式?

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

I have several rails applications that will use the same core set of Models and data, for example: 我有几个rails应用程序将使用相同的核心模型和数据集,例如:

  • 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) Rails引擎(可以解决不同应用程序中的重复模型问题,但不会解决共享数据问题)
  • Using ActiveResource to access the core data (solves the shared data, but not the shared model issue) 使用ActiveResource访问核心数据(解决共享数据,但不解决共享模型问题)

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. 我正在使用共享数据库来解决heroku和EC2上的服务器之间的共享数据问题,该问题执行了一些我无法在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. 在我的情况下,我使用相同的应用程序,但实际上我正在做的就是在EC2上使用delayed_job,所以我只使用应用程序中的模型。 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. 如果我打算在另一个应用程序中使用它们,我可能会遇到创建在它们之间使用的gem的麻烦。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Rails ActiveRecord-比较不同模型中的关联数据 - Rails ActiveRecord - Comparing Associated Data in Different Models 在 Rails 中的 Javascript 和 Sass 之间共享数据的最佳方式? - Best way to share data between Javascript and Sass in Rails? ActiveRecord:在没有Rails的情况下使用ActiveRecord时如何在AR模型之间共享连接 - ActiveRecord: how to share connections between AR-models when using ActiveRecord without Rails 在不同版本的两个 Rails 应用程序之间共享设计会话 cookie - Share Devise session cookie between two Rails apps of different versions Rails:是否可以在具有两个不同数据库的两个应用程序之间共享会话? - Rails: is it possible to share session between two apps with two different databases? 在Rails应用之间共享功能的理想方式是什么? - What would be ideal way to share functionality between Rails apps? 在同一域中的节点应用程序和Rails之间共享身份验证数据的最佳方法 - Best way to share authentication data between a node app and a rails one on same domain 在Rails 3中使用ActiveRecord插入非模型数据的最佳方法? - Best way to insert non-model data using ActiveRecord in Rails 3? 如何在Rails的多个数据模型之间共享类方法? - How to share class methods between multiple data models in Rails? 如何在Ruby on Rails中的两个模型之间共享数据 - How to share data between two models in Ruby on Rails
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM