Permalink
Browse files

Try to guess application's directory while trying to run the server, …

…but only if config.ru is not present in current dir
  • Loading branch information...
1 parent 3049e64 commit 9f569c60adb3505cd7ca1723481199bf26619038 @drogus drogus committed Sep 29, 2010
Showing with 5 additions and 0 deletions.
  1. +5 −0 railties/lib/rails/commands.rb
@@ -33,8 +33,13 @@
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

0 comments on commit 9f569c6

Please sign in to comment.