diff options
author | Piotr Sarnacki <drogus@gmail.com> | 2010-09-29 22:31:58 +0200 |
---|---|---|
committer | Piotr Sarnacki <drogus@gmail.com> | 2010-09-30 10:27:55 +0200 |
commit | 9f569c60adb3505cd7ca1723481199bf26619038 (patch) | |
tree | 0c74273f34c20e56975a6b7845a034fa3df8c469 /railties/lib/rails | |
parent | 3049e645e5037cd923d0bad3c41c105dd9d791f8 (diff) | |
download | rails-9f569c60adb3505cd7ca1723481199bf26619038.tar.gz rails-9f569c60adb3505cd7ca1723481199bf26619038.tar.bz2 rails-9f569c60adb3505cd7ca1723481199bf26619038.zip |
Try to guess application's directory while trying to run the server, but only if config.ru is not present in current dir
Diffstat (limited to 'railties/lib/rails')
-rw-r--r-- | railties/lib/rails/commands.rb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/railties/lib/rails/commands.rb b/railties/lib/rails/commands.rb index acabdcac93..60b9a55d80 100644 --- a/railties/lib/rails/commands.rb +++ b/railties/lib/rails/commands.rb @@ -33,8 +33,13 @@ when 'console' Rails::Console.start(Rails.application) when 'server' + # try to guess application's path if there is no config.ru file in current dir + # it allows to run script/rails server from other directories + Dir.chdir(File.expand_path('../../', APP_PATH)) unless File.exists?(File.expand_path("config.ru")) + require 'rails/commands/server' Rails::Server.new.tap { |server| + # we need to require application after the server sets environment require APP_PATH Dir.chdir(Rails.application.root) server.start |