Managing Gem dependencies with Rails >= 2.0.3
This is how I manage gem dependencies for Rails applications that use Rails >= 2.0.3.
Specify the dependencies in config.rb
.
Rails::Initializer.run do |config|
# ...
config.gem 'doodle'
config.gem 'aws-s3', :lib => 'aws/s3'
config.gem 'smqueue', :version => '0.1.0'
# ...
end
Since I don't want to make my deployment depend on all the gem sources being available I tend to pull the gems into the source tree and check them in.
sudo rake gems:install
rake gems:unpack
svn add vendor/gems/*
When it's time to deploy the application remember to build the gems that have native extensions.
rake gems:build
If you've got some sort of build system in place that produces application packages then this should be done as part of building that package. If you're using Capistrano then it should be done in an after deploy:update_code
callback.
Disagree? Found a typo? Got a question? Email me at craig@barkingiguana.com.