包装Rails 2.3模型 [英] Packaging Rails 2.3 Models
问题描述
我有一个在Rails上运行的现有webapp。计划是设置一个新的服务器,它将提供一个API服务,并最终将webapp更新为该API的客户端。
这似乎是一种很好的方法实现这一目标将把所有模型打包为宝石并在两种应用程序之间共享。最终,API服务将是单一的 - 包含所有模型,但有一段时间的开发/迁移需要共享模型。
API和web应用程序都将使用同一个数据库。
模型?
单个宝石中,单独打包每个模型还是做某种排序是值得的
模型的逻辑分组?
宝石的依赖关系?
作为参考,下面是一个类似的问题:
使用gems共享Rails应用程序之间的模型
我还熟悉将Ruby代码打包为Rubygem。 (这可能解释了我上面的一些问题。)
我使用Rails 2.3.14,而不是Rails 3.X。
过去,我们已经完成了将模型包装到宝石中。我们开始时移动了一组相互关联的模型,但没有其他模型的其他依赖关系。然后我们慢慢地移动另一个组。这有点痛苦,但我们最终做到了。模型宝石在多个应用程序中共享。
I've got an existing webapp running on Rails. The plan is to setup a new server which will provide an API service, and eventually update the webapp to be a client of this API.
It seems like a good approach to achieving this would be packaging all the models as gems and sharing them between the two applications. Eventually the API service would be monolithic - containing all the models, but there is a period of development/migration where models will need to be shared.
Both the API and the webapp will be using the same database.
- What do I need to consider before jumping into packaging up all my models?
- Would it be worthwhile to package all the models into a single gem, individually package each model, or do some sort of logical grouping of models?
- How would I approach dependencies for gems?
For reference, here's a similar-ish question: Sharing models between Rails apps using gems
I'm also just getting familiar with packaging Ruby code as a Rubygem. (This might explain some of my questions above.)
[edit] I'm using Rails 2.3.14, not Rails 3.X.
We have done packaging models to a gem in the past. We started out by moving a group of models that are associated with each other but have no other dependency of the rest of the models. Then we slowly move another group. It is a bit painful but we eventually did it. The model gems are shared among several apps.
这篇关于包装Rails 2.3模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!