Skip to content

Instantly share code, notes, and snippets.

@diogenes
Created July 16, 2010 14:13
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 diogenes/478415 to your computer and use it in GitHub Desktop.
Save diogenes/478415 to your computer and use it in GitHub Desktop.
# add this to the bottom of config/boot.rb, before the line `Rails.boot!`
class Rails::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
# include at least one source and the rails gem
source :gemcutter
gem "rails", "~> 2.3.5", :require => nil
gem "sqlite3-ruby", :require => "sqlite3"
# Devise 1.0.2 is not a valid gem plugin for Rails, so use git until 1.0.3
# gem "devise", :git => "git://github.com/plataformatec/devise.git", :ref => "v1.0"
group :development do
# bundler requires these gems in development
gem 'rails-footnotes'
end
group :test do
# bundler requires these gems while running tests
gem 'rspec'
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"
# we have to do the 'if' like this because Ruby won't compare micro version numbers accurately
version = Bundler::VERSION.split(".").map{|v| v.to_i}
if version[0] == 0 and version[1] <= 9 and version[2] <= 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment