aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
Diffstat (limited to 'railties')
-rw-r--r--railties/CHANGELOG2
-rwxr-xr-xrailties/bin/rails19
-rw-r--r--railties/lib/initializer.rb10
-rw-r--r--railties/lib/ruby_version_check.rb17
4 files changed, 29 insertions, 19 deletions
diff --git a/railties/CHANGELOG b/railties/CHANGELOG
index ef1144b546..bc27d2692e 100644
--- a/railties/CHANGELOG
+++ b/railties/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Reject Ruby 1.8.3 when loading Rails; extract version checking code. [Chad Fowler]
+
* Remove explicit loading of RailsInfo and RailsInfoController. [Nicholas Seckar]
* Move RailsInfo and RailsInfoController to Rails::Info and Rails::InfoController. [Nicholas Seckar]
diff --git a/railties/bin/rails b/railties/bin/rails
index 7e66672b33..a07b02daac 100755
--- a/railties/bin/rails
+++ b/railties/bin/rails
@@ -1,21 +1,4 @@
-min_release = "1.8.2 (2004-12-25)"
-ruby_release = "#{RUBY_VERSION} (#{RUBY_RELEASE_DATE})"
-if ruby_release =~ /1\.8\.3/
- abort <<-end_message
-
- Rails does not work with Ruby version 1.8.3.
- Please upgrade to version 1.8.4 or downgrade to 1.8.2.
-
- end_message
-elsif ruby_release < min_release
- abort <<-end_message
-
- Rails requires Ruby version #{min_release} or later.
- You're running #{ruby_release}; please upgrade to continue.
-
- end_message
-end
-
+require File.dirname(__FILE__) + '/../lib/ruby_version_check'
Signal.trap("INT") { puts; exit }
require File.dirname(__FILE__) + '/../lib/rails_version'
diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb
index 132c70cd21..eed5c16d9c 100644
--- a/railties/lib/initializer.rb
+++ b/railties/lib/initializer.rb
@@ -74,6 +74,7 @@ module Rails
# environment could overwrite the defaults directly, instead of via the
# Configuration instance.
def process
+ check_ruby_version
set_load_path
set_connection_adapters
@@ -106,7 +107,14 @@ module Rails
# the framework is now fully initialized
after_initialize
end
-
+
+ # Check for valid Ruby version
+ # This is done in an external file, so we can use it
+ # from the `rails` program as well without duplication.
+ def check_ruby_version
+ require 'ruby_version_check'
+ end
+
# Set the <tt>$LOAD_PATH</tt> based on the value of
# Configuration#load_paths. Duplicates are removed.
def set_load_path
diff --git a/railties/lib/ruby_version_check.rb b/railties/lib/ruby_version_check.rb
new file mode 100644
index 0000000000..68d3acc876
--- /dev/null
+++ b/railties/lib/ruby_version_check.rb
@@ -0,0 +1,17 @@
+min_release = "1.8.2 (2004-12-25)"
+ruby_release = "#{RUBY_VERSION} (#{RUBY_RELEASE_DATE})"
+if ruby_release =~ /1\.8\.3/
+ abort <<-end_message
+
+ Rails does not work with Ruby version 1.8.3.
+ Please upgrade to version 1.8.4 or downgrade to 1.8.2.
+
+ end_message
+elsif ruby_release < min_release
+ abort <<-end_message
+
+ Rails requires Ruby version #{min_release} or later.
+ You're running #{ruby_release}; please upgrade to continue.
+
+ end_message
+end