Packaging Rails 2.3 Models

别等时光非礼了梦想. 提交于 2019-12-13 16:24:10

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/8406826/packaging-rails-2-3-models

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