diff options
author | Carl Lerche <carllerche@mac.com> | 2009-10-16 16:01:46 -0700 |
---|---|---|
committer | Carl Lerche <carllerche@mac.com> | 2009-10-16 16:03:14 -0700 |
commit | 591eaf3b2c56ebb8a779c3ebbd1300a3f776f39a (patch) | |
tree | 4aeeda306df0237c10cba7f06ed575761fc9eb81 /railties | |
parent | 2ca93403a259a8e6cead1c3a6eba675df9f1586a (diff) | |
download | rails-591eaf3b2c56ebb8a779c3ebbd1300a3f776f39a.tar.gz rails-591eaf3b2c56ebb8a779c3ebbd1300a3f776f39a.tar.bz2 rails-591eaf3b2c56ebb8a779c3ebbd1300a3f776f39a.zip |
Get apps generated with working again.
Diffstat (limited to 'railties')
-rw-r--r-- | railties/lib/rails/commands/server.rb | 2 | ||||
-rw-r--r-- | railties/lib/rails/generators/rails/app/templates/config/boot.rb | 93 |
2 files changed, 44 insertions, 51 deletions
diff --git a/railties/lib/rails/commands/server.rb b/railties/lib/rails/commands/server.rb index d29fa620fb..29359e49a4 100644 --- a/railties/lib/rails/commands/server.rb +++ b/railties/lib/rails/commands/server.rb @@ -7,7 +7,7 @@ options = { :Port => 3000, :Host => "0.0.0.0", :environment => (ENV['RAILS_ENV'] || "development").dup, - :config => Rails.root + "/config.ru", + :config => "#{Rails.root}/config.ru", :detach => false, :debugger => false } diff --git a/railties/lib/rails/generators/rails/app/templates/config/boot.rb b/railties/lib/rails/generators/rails/app/templates/config/boot.rb index 12152a5d54..928b195d8d 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/boot.rb +++ b/railties/lib/rails/generators/rails/app/templates/config/boot.rb @@ -10,38 +10,33 @@ module Rails class << self def boot! unless booted? - preinitialize - pick_boot.run + root = File.expand_path('../..', __FILE__) + booter = File.exist?("#{root}/vendor/rails") ? VendorBoot : GemBoot + booter.new(root).run end end def booted? defined? Rails::Initializer end - - def pick_boot - (vendor_rails? ? VendorBoot : GemBoot).new - end - - def vendor_rails? - File.exist?("#{RAILS_ROOT}/vendor/rails") - end - - def preinitialize - load(preinitializer_path) if File.exist?(preinitializer_path) - end - - def preinitializer_path - "#{RAILS_ROOT}/config/preinitializer.rb" - end end class Boot + def initialize(root) + @root = root + end + def run + preinitialize set_load_paths load_initializer end + def preinitialize + path = "#{@root}/config/preinitializer.rb" + load(path) if File.exist?(path) + end + def set_load_paths %w( actionmailer/lib @@ -60,7 +55,7 @@ module Rails end def framework_root_path - defined?(::RAILS_FRAMEWORK_ROOT) ? ::RAILS_FRAMEWORK_ROOT : "#{RAILS_ROOT}/vendor/rails" + defined?(::RAILS_FRAMEWORK_ROOT) ? ::RAILS_FRAMEWORK_ROOT : "#{@root}/vendor/rails" end end @@ -85,13 +80,13 @@ module Rails class GemBoot < Boot def load_initializer - self.class.load_rubygems + load_rubygems load_rails_gem require 'rails' end def load_rails_gem - if version = self.class.gem_version + if version = gem_version gem 'rails', version else gem 'rails' @@ -101,43 +96,41 @@ module Rails exit 1 end - class << self - def rubygems_version - Gem::RubyGemsVersion rescue nil - end + def rubygems_version + Gem::RubyGemsVersion rescue nil + end - def gem_version - if defined? RAILS_GEM_VERSION - RAILS_GEM_VERSION - elsif ENV.include?('RAILS_GEM_VERSION') - ENV['RAILS_GEM_VERSION'] - else - parse_gem_version(read_environment_rb) - end + def gem_version + if defined? RAILS_GEM_VERSION + RAILS_GEM_VERSION + elsif ENV.include?('RAILS_GEM_VERSION') + ENV['RAILS_GEM_VERSION'] + else + parse_gem_version(read_environment_rb) end + end - def load_rubygems - min_version = '1.3.2' - require 'rubygems' - unless rubygems_version >= min_version - $stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.) - exit 1 - end - - rescue LoadError - $stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org) + def load_rubygems + min_version = '1.3.2' + require 'rubygems' + unless rubygems_version >= min_version + $stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.) exit 1 end - def parse_gem_version(text) - $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/ - end + rescue LoadError + $stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org) + exit 1 + end - private - def read_environment_rb - File.read("#{RAILS_ROOT}/config/environment.rb") - end + def parse_gem_version(text) + $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/ end + + private + def read_environment_rb + File.read("#{@root}/config/environment.rb") + end end end |