Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save cbrunnkvist/461264 to your computer and use it in GitHub Desktop.
Save cbrunnkvist/461264 to your computer and use it in GitHub Desktop.
Adds bundler loader to Rails 2.3.x projects
From ce29c8fe3a51a4652c0942e4995bdebd0871dc06 Mon Sep 17 00:00:00 2001
From: Conny Brunnkvist <[email protected]>
Date: Tue, 22 Jun 2010 12:02:58 +0100
Subject: [PATCH] Adding Bundler-compat patches for Rails 2.3.8
---
config/boot.rb | 16 +++++++++++++++-
config/preinitializer.rb | 21 +++++++++++++++++++++
2 files changed, 36 insertions(+), 1 deletions(-)
create mode 100644 config/preinitializer.rb
diff --git a/config/boot.rb b/config/boot.rb
index dd5e3b6..5c01c00 100644
--- a/config/boot.rb
+++ b/config/boot.rb
@@ -1,4 +1,4 @@
-# Don't change this file!
+# Don't change this file! <<< let's change this
# Configure your app in config/environment.rb and config/environments/*.rb
RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
@@ -106,5 +106,19 @@ module Rails
end
end
+#Monkey-patch from gembundler.com
+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!
diff --git a/config/preinitializer.rb b/config/preinitializer.rb
new file mode 100644
index 0000000..fab57a8
--- /dev/null
+++ b/config/preinitializer.rb
@@ -0,0 +1,21 @@
+#from gembundler.com
+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." +
+ "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
--
1.7.0.6+GitX
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment