Skip to content

Commit

Permalink
Try to guess application's directory while trying to run the server, …
Browse files Browse the repository at this point in the history
…but only if config.ru is not present in current dir
  • Loading branch information
drogus committed Sep 30, 2010
1 parent 3049e64 commit 9f569c6
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions railties/lib/rails/commands.rb
Expand Up @@ -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
Expand Down

0 comments on commit 9f569c6

Please sign in to comment.