Skip to content

Instantly share code, notes, and snippets.

@stevenhaddox
Created July 1, 2010 22:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevenhaddox/460656 to your computer and use it in GitHub Desktop.
Save stevenhaddox/460656 to your computer and use it in GitHub Desktop.
class Boot
def run
load_initializer
extend_environment
Rails::Initializer.run(:set_load_path)
end
def extend_environment
Rails::Initializer.class_eval do
old_load = instance_method(:load_environment)
define_method(:load_environment) do
Bundler.require :default, Rails.env
old_load.bind(self).call
end
end
end
end
begin
# Require the preresolved locked set of gems.
require File.expand_path('../../.bundle/environment', __FILE__)
rescue LoadError
# Fallback on doing the resolve at runtime.
require "rubygems"
require "bundler"
if Bundler::VERSION <= "0.9.5"
raise RuntimeError, "Bundler incompatible.\n" +
"Your bundler version is incompatible with Rails 2.3 and an unlocked bundle.\n" +
"Run `gem install bundler` to upgrade or `bundle lock` to lock."
else
Bundler.setup
end
end
@stevenhaddox
Copy link
Author

Fairly obvious that boot.rb is in app_root_path/config; preinitializer.rb also lives in your config directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment