diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2006-04-01 05:55:47 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2006-04-01 05:55:47 +0000 |
commit | 53e1e50e0475fbb6009fc60ad374e9788ab710cd (patch) | |
tree | 3df2c8602c586222454ea2e49abfcb1f728e0356 /railties | |
parent | a09b202e8321717921ff729d4a1233770fd52be4 (diff) | |
download | rails-53e1e50e0475fbb6009fc60ad374e9788ab710cd.tar.gz rails-53e1e50e0475fbb6009fc60ad374e9788ab710cd.tar.bz2 rails-53e1e50e0475fbb6009fc60ad374e9788ab710cd.zip |
Specify gem version in environment.rb
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4111 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'railties')
-rw-r--r-- | railties/environments/boot.rb | 22 | ||||
-rw-r--r-- | railties/environments/environment.rb | 3 | ||||
-rw-r--r-- | railties/lib/rails_generator/generators/applications/app/app_generator.rb | 4 |
3 files changed, 21 insertions, 8 deletions
diff --git a/railties/environments/boot.rb b/railties/environments/boot.rb index a57f0f46da..ad0dcd6583 100644 --- a/railties/environments/boot.rb +++ b/railties/environments/boot.rb @@ -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)
\ No newline at end of file diff --git a/railties/environments/environment.rb b/railties/environments/environment.rb index f548b23447..5fbceb69dc 100644 --- a/railties/environments/environment.rb +++ b/railties/environments/environment.rb @@ -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') diff --git a/railties/lib/rails_generator/generators/applications/app/app_generator.rb b/railties/lib/rails_generator/generators/applications/app/app_generator.rb index b1f8942652..145f354052 100644 --- a/railties/lib/rails_generator/generators/applications/app/app_generator.rb +++ b/railties/lib/rails_generator/generators/applications/app/app_generator.rb @@ -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" |