Skip to content

Instantly share code, notes, and snippets.

@mrrooijen
Created May 13, 2010 23:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save mrrooijen/400609 to your computer and use it in GitHub Desktop.
Save mrrooijen/400609 to your computer and use it in GitHub Desktop.
Bundler in Rails 2.
## config/boot.rb
# Place this snippet right above the "Rails.boot!" command at the bottom of the file.
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
## config/preinitializer.rb
# Create this file and paste the code in
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"
Bundler.setup
end
## Install bundler
# cd /path/to/RAILS_ROOT
# gem install bundler
# bundle init
## Generates a Gemfile in the RAILS_ROOT
# Here's a simple template to start off with
# Default RubyGems Source
source :gemcutter
# Ruby on Rails Framework Requirements
gem "rails", "2.3.5"
gem "rack", "1.0.1"
# Additional Gems
gem "sqlite3-ruby"
# Gems specifically for development environment
group :development do
gem "hirb"
end
# Gems specifically for test environment
group :test do
gem "rspec"
gem "rspec-rails"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment