在两个Rails项目之间共享模型

编程入门 行业动态 更新时间:2024-10-23 20:26:19
本文介绍了在两个Rails项目之间共享模型 - 使用git子模块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

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

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

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

解决方案

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

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

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

更多推荐

在两个Rails项目之间共享模型

本文发布于:2023-11-25 22:39:02,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1631633.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:模型   两个   项目   Rails

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!