314 | Chapter 10: Large Projects
There is one caveat to this approach. Subversion will not commit to two repositories
at once, and it sees an external as a separate repository. So, if you make changes to
both the models and some other part of an application at the same time, you must
check those changes in separately. This can take some getting used to, but it quickly
becomes second nature.
Depending on your situation, you may want to keep any or all of these shared
between two or more Rails applications:
Rails codebase
Usually, you want all of the applications within a project to be locked to the
same version of Rails. With a project maintained under Subversion, using Piston
to source the vendor code offers an advantage; you can maintain local changes to
the Rails tree independently of what happens upstream. Using Piston, you can
lock Rails to a certain branch (stable or edge) and update when you feel like it.
You can pull changes from the upstream Rails repository and sync them
throughouttrunk with the following commands:
$ cd project/trunk
$ piston update rails
$ svn up
Plugins
Like the Rails source, plugins usually come in from an upstream repository.
Often you will need them synchronized across projects. Here, Piston is a great
help again, as you can update across your project and only pull changes from
upstream when you are ready. You have two options for structuring the source
tree: you can either pull the plugins directory as a whole (intovendor/plugins), or
you can cherry-pick the plugins you need for each application.
RubyGems
Maintaining gem dependencies between development environments, staging,
and production servers can be a hassle. The most consistent solution is to “ven-
dor everything”—create avendor/gemsdirectory, carry your gem dependencies
around with the project code, and modify Rails to look there before your
installed RubyGems.
Chris Wanstrath came up with this solution (http://errtheblog.com/post/2120),
and Dr. Nic Williams packaged it into a gem itself, gemsonrails (http://
gemsonrails.rubyforge.org/). Kyle Maxwell has a Rails plugin that allows the
“vendor everything” approach to be used for gems that require building native
extensions (http://svn.kylemaxwell.com/rails_plugins/vendor_everything_extensions/).