diff options
-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" |