views:

184

answers:

2

Rather than using the latest Rails gem for my application, I like to have the code local in my own git repository, which means putting it in vendor/rails.

There are a couple of ways of doing this: downloading the source for the particular branch/tag I want to run and committing it to my repository, or using git submodules.

Submodules seem like a natural way to go, but isn't it the case that each time you clone the repository you'll have to manually check out the branch you want to use that submodule for (otherwise you'll just get master)? And is there an impact on Capistrano deployments using this method?

+1  A: 

Hi Olly,

I'd recommend freezing on a release:

rake rails:freeze:edge RELEASE=2.3.3

There is a git branch for 2-3-stable, but I've had a terrible time using it. Submodules are a bit of a pain. The tool Braid is pretty nice, but I like freezing Rails with releases.

Capistrano is going to be a little more sluggish deploying your code (the whole Rails codebase is in there), but capistrano itself and your production setup should not need to be altered.

Good luck!

mixonic
+1  A: 

Hi Olly,

Capistrano supports submodules and, if you are deploying via remote_cache, deployment is nice and fast. In your deploy.rb you need:

set :git_enable_submodules, true set :deploy_via, :remote_cache

I'm not quite sure what you mean when you ask about cloning the repository. Once you have vendored Rails as a submodule, you can pin it to a specific commit/tag/branch. This stores a kind of distributed symlink (at least that's the way I think of it) in your repo, pointing to the Rails commit in question. When you clone your repo, that commit's tree will be automatically pulled down too (I think!).

I went through this myself a couple of months ago and wrote it up here. It's working well for me.

http://blog.airbladesoftware.com/2009/4/28/how-to-vendor-rails

Andy Stewart
Hi Andy :)Thanks for the info. I did follow you blog post originally but we encountered a number of issues with submodules. For instance, when you first clone the repo I found you needed to do a 'git submodule init' etc. This is less than ideal when you have a number of users of the repo and some of them are not that technical. I wanted the simplest solution, and rake rails:freeze:edge seemed to work well for me.
Olly
Hi Olly :) Simple is good, I'm glad rake rails:freeze:edge does the job.
Andy Stewart