在两个Rails项目之间共享模型 - 使用git子模块? [英] Sharing Models between two Rails Projects - using git submodules?

查看:131
本文介绍了在两个Rails项目之间共享模型 - 使用git子模块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Rails网站,它被分成两个独立的项目 - 公共站点和管理站点。



由于两个站点使用相同的数据库,模型在应用程序之间共享(实际上现在它们被复制)。我在这里遇到的问题是,当公共项目中出现模型更新时,我需要将更改复制到管理项目中。



我已经有了一个看看周围所以,并注意到有一个问题有答案建议使用svn:external或git子模块,但我不完全确定如何执行此操作。



本质上,我的目标是能够仅在一个位置进行更改,将这些更改提交到 git ,然后当我需要更新时,能够在另一个项目中提取更改。

解决方案

不要使用子模块。他们很丑,很难理解和维护。



Git子树是Git 1.7.11以来的一部分,我写了一篇关于在Rails应用程序之间共享代码的文章: http:// igor -alexandrov.github.com/blog/2013/03/28/using-git-subtree-to-share-code-between-rails-applications/

<总之:是的,git-subtree的工作原理非常棒!


I have a Rails website which has been divided into two separate projects - the public site, and the administration site.

As both sites are using the same database the models are shared between the applications (actually right now they are duplicated). The problem I have here is that when an update to the models occurs in the public project I need to copy the changes over into the admin project.

I've had a look around SO and noticed that there was a question which had answers suggesting using svn:external or git submodule, but I'm not entirely sure how to do this.

Essentially my aim is to be able to make the changes in one place only, commit those changes to git and then be able to pull the changes in the other project when I need to update that as well.

解决方案

Do not use submodules. They are ugly, hard to understand and to maintain. Much better is to use subtrees.

Git subtree is a part of GIT since 1.7.11 and I wrote an article about sharing code between Rails applications: http://igor-alexandrov.github.com/blog/2013/03/28/using-git-subtree-to-share-code-between-rails-applications/

In short: yes git-subtree works and works great!

这篇关于在两个Rails项目之间共享模型 - 使用git子模块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆