🕷 zenspider.com

by ryan davis



sitemap
Looking for the Ruby Quickref?

Isolate for Rails Apps

Published 2010-02-04 @ 14:17

Tagged rails, Seattle.rb

I work on a lot of stuff. I’d rather have my laptop’s gem installs be for my stuff, not my work stuff. I’d especially rather not deal with the version mess you get into when you’ve got several different rails apps. Isolate makes this incredibly easy. With just one gem system-installed, you can make every project completely standalone:

A New Rails App:

% rails blah

You can use isolate with just two files in your rails app. You just add the following:

config/preinitializer.rb

1
2
3
ENV['RAILS_ENV'] ||= 'development' # le sigh

require 'config/gems'

config/gems.rb

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
require "rubygems"
require "isolate"

Isolate.gems "vendor/isolated" do
  gem "rails", "= 2.0.2"

  environment :development do
    gem "vlad"
    gem "sqlite3-ruby"
  end

  environment :test do
    gem "minitest"
  end
end

and then…

% rake -t
(in /Users/ryan/blah2)
[1/3] Isolating rails (= 2.0.2).
[2/3] Isolating vlad (>= 0).
[3/3] Isolating sqlite3-ruby (>= 0).
Building native extensions.  This could take a while...

That’s it! It has really made my work a lot easier! I don’t have to deal with umpteen different dependencies that I’ll never use on another project. I never need to have unknown artifacts breaking stuff. Everything is very cleanly documented within the Isolate.gems block. I love isolate. You should check it out if you haven’t already.