diff --git a/railties/CHANGELOG b/railties/CHANGELOG index 99fcd06c3b..3e661e527b 100644 --- a/railties/CHANGELOG +++ b/railties/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Teach Rails apps to only load gems of the same Rails version they were generated with. [Nicholas Seckar] + * Added expiration settings for JavaScript, CSS, HTML, and images to default lighttpd.conf [DHH] * Added gzip compression for JavaScript, CSS, and HTML to default lighttpd.conf [DHH] diff --git a/railties/environments/boot.rb b/railties/environments/boot.rb index 9fcd50fe3f..a57f0f46da 100644 --- a/railties/environments/boot.rb +++ b/railties/environments/boot.rb @@ -13,7 +13,12 @@ if File.directory?("#{RAILS_ROOT}/vendor/rails") require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer" else require 'rubygems' - require 'initializer' + 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." + end + require rails_gem.full_gem_path + '/lib/initializer' end Rails::Initializer.run(:set_load_path) 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 1211b512d7..b1f8942652 100644 --- a/railties/lib/rails_generator/generators/applications/app/app_generator.rb +++ b/railties/lib/rails_generator/generators/applications/app/app_generator.rb @@ -43,7 +43,7 @@ class AppGenerator < Rails::Generator::Base m.template "configs/apache.conf", "public/.htaccess" # Environments - m.file "environments/boot.rb", "config/boot.rb" + m.template "environments/boot.rb", "config/boot.rb" m.file "environments/environment.rb", "config/environment.rb" m.file "environments/production.rb", "config/environments/production.rb" m.file "environments/development.rb", "config/environments/development.rb"