Permalink
Browse files

Using Bundler in the built-in Rails 2 app (yay!)

  • Loading branch information...
Paul Engel
Paul Engel committed Nov 8, 2010
1 parent afa9c5d commit 4daa3cc658cc74c0d8846252405544cd9e5adccb
Showing with 39 additions and 0 deletions.
  1. +5 −0 test/rails-2/dummy/Gemfile
  2. +14 −0 test/rails-2/dummy/config/boot.rb
  3. +20 −0 test/rails-2/dummy/config/preinitializer.rb
@@ -0,0 +1,5 @@
+source "http://rubygems.org"
+
+gem "rails", "2.3.8"
+gem "sqlite3-ruby", :require => "sqlite3"
+gem "rich_i18n", :path => File.join(File.dirname(__FILE__), "..", "..", "..")
@@ -106,5 +106,19 @@ def read_environment_rb
end
end
+class Rails::Boot
+ def run
+ load_initializer
+
+ Rails::Initializer.class_eval do
+ def load_gems
+ @bundler_loaded ||= Bundler.require :default, Rails.env
+ end
+ end
+
+ Rails::Initializer.run(:set_load_path)
+ end
+end
+
# All that for this:
Rails.boot!
@@ -0,0 +1,20 @@
+begin
+ require "rubygems"
+ require "bundler"
+rescue LoadError
+ raise "Could not load the bundler gem. Install it with `gem install bundler`."
+end
+
+if Gem::Version.new(Bundler::VERSION) <= Gem::Version.new("0.9.24")
+ raise RuntimeError, "Your bundler version is too old for Rails 2.3." +
+ "Run `gem install bundler` to upgrade."
+end
+
+begin
+ # Set up load paths for all bundled gems
+ ENV["BUNDLE_GEMFILE"] = File.expand_path("../../Gemfile", __FILE__)
+ Bundler.setup
+rescue Bundler::GemNotFound
+ raise RuntimeError, "Bundler couldn't find some gems." +
+ "Did you run `bundle install`?"
+end

0 comments on commit 4daa3cc

Please sign in to comment.