Specify gem version in environment.rb

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4111 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
David Heinemeier Hansson
2006-04-01 05:55:47 +00:00
parent a09b202e83
commit 53e1e50e04
3 changed files with 21 additions and 8 deletions

View File

@@ -13,12 +13,22 @@ if File.directory?("#{RAILS_ROOT}/vendor/rails")
require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
else
require 'rubygems'
required_version = '<%= Rails::VERSION::STRING %>'
rails_gem = Gem.cache.search('rails', "=#{required_version}").first
unless rails_gem
STDERR.puts "Cannot find gem for Rails =#{required_version}. Install missing gem or change config/boot.rb."
if !defined?(RAILS_GEM_VERSION) && File.read(File.dirname(__FILE__) + '/environment.rb') =~ /RAILS_GEM_VERSION = '([\d.]+)'/
RAILS_GEM_VERSION = $1
end
if defined?(RAILS_GEM_VERSION)
rails_gem = Gem.cache.search('rails', "=#{RAILS_GEM_VERSION}").first
if rails_gem
require rails_gem.full_gem_path + '/lib/initializer'
else
STDERR.puts "Cannot find gem for Rails =#{RAILS_GEM_VERSION}. Install missing gem or change config/boot.rb."
end
else
require 'initializer'
end
require rails_gem.full_gem_path + '/lib/initializer'
end
Rails::Initializer.run(:set_load_path)
Rails::Initializer.run(:set_load_path)

View File

@@ -4,6 +4,9 @@
# you don't control web/app server and can't set it the proper way
# ENV['RAILS_ENV'] ||= 'production'
# Specifies gem version of Rails to use when vendor/rails is not present
RAILS_GEM_VERSION = '<%= Rails::VERSION::STRING %>'
# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot')

View File

@@ -43,8 +43,8 @@ class AppGenerator < Rails::Generator::Base
m.template "configs/apache.conf", "public/.htaccess"
# Environments
m.template "environments/boot.rb", "config/boot.rb"
m.file "environments/environment.rb", "config/environment.rb"
m.file "environments/boot.rb", "config/boot.rb"
m.template "environments/environment.rb", "config/environment.rb"
m.file "environments/production.rb", "config/environments/production.rb"
m.file "environments/development.rb", "config/environments/development.rb"
m.file "environments/test.rb", "config/environments/test.rb"