diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2010-01-11 14:01:28 -0800 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2010-01-11 14:01:28 -0800 |
commit | 8cb594a2e1808cd7d93f3593afed0414016fc56f (patch) | |
tree | 766eeb882eb4cfd9a6a13893a7b0ca7f35811650 /railties/lib/rails/commands | |
parent | a9eebde8561df5c7c34669587c9e25e8baeeeabb (diff) | |
download | rails-8cb594a2e1808cd7d93f3593afed0414016fc56f.tar.gz rails-8cb594a2e1808cd7d93f3593afed0414016fc56f.tar.bz2 rails-8cb594a2e1808cd7d93f3593afed0414016fc56f.zip |
Get everyone running on Rails.env and fix the broken environment settings for script/console and script/dbconsole
Diffstat (limited to 'railties/lib/rails/commands')
-rw-r--r-- | railties/lib/rails/commands/console.rb | 11 | ||||
-rw-r--r-- | railties/lib/rails/commands/dbconsole.rb | 6 | ||||
-rw-r--r-- | railties/lib/rails/commands/runner.rb | 1 | ||||
-rw-r--r-- | railties/lib/rails/commands/server.rb | 7 |
4 files changed, 13 insertions, 12 deletions
diff --git a/railties/lib/rails/commands/console.rb b/railties/lib/rails/commands/console.rb index d154808029..27ac7fd20a 100644 --- a/railties/lib/rails/commands/console.rb +++ b/railties/lib/rails/commands/console.rb @@ -4,8 +4,6 @@ require "irb/completion" module Rails class Console - ENVIRONMENTS = %w(production development test) - def self.start(app) new(app).start end @@ -25,10 +23,6 @@ module Rails opt.parse!(ARGV) end - if env = ARGV.pop - ENV['RAILS_ENV'] = ENVIRONMENTS.find { |e| e.index(env) } || env - end - @app.initialize! require "rails/console_app" require "rails/console_sandbox" if options[:sandbox] @@ -54,3 +48,8 @@ module Rails end end end + +# Has to set the RAILS_ENV before config/application is required +if ARGV.first && !ARGV.first.index("-") && env = ARGV.pop # has to pop the env ARGV so IRB doesn't freak + ENV['RAILS_ENV'] = %w(production development test).find { |e| e.index(env) } || env +end diff --git a/railties/lib/rails/commands/dbconsole.rb b/railties/lib/rails/commands/dbconsole.rb index 77c3404343..b836a17a49 100644 --- a/railties/lib/rails/commands/dbconsole.rb +++ b/railties/lib/rails/commands/dbconsole.rb @@ -34,7 +34,6 @@ module Rails abort opt.to_s unless (0..1).include?(ARGV.size) end - env = ARGV.first || ENV['RAILS_ENV'] || 'development' unless config = YAML::load(ERB.new(IO.read("#{@app.root}/config/database.yml")).result)[env] abort "No database is configured for the environment '#{env}'" end @@ -97,4 +96,9 @@ module Rails end end end +end + +# Has to set the RAILS_ENV before config/application is required +if ARGV.first && !ARGV.first.index("-") && env = ARGV.first + ENV['RAILS_ENV'] = %w(production development test).find { |e| e.index(env) } || env end
\ No newline at end of file diff --git a/railties/lib/rails/commands/runner.rb b/railties/lib/rails/commands/runner.rb index 0246348c77..4487d2e7b1 100644 --- a/railties/lib/rails/commands/runner.rb +++ b/railties/lib/rails/commands/runner.rb @@ -34,7 +34,6 @@ end ARGV.delete(code_or_file) ENV["RAILS_ENV"] = options[:environment] -RAILS_ENV.replace(options[:environment]) if defined?(RAILS_ENV) begin if code_or_file.nil? diff --git a/railties/lib/rails/commands/server.rb b/railties/lib/rails/commands/server.rb index 09d7207d51..b21ae2a17b 100644 --- a/railties/lib/rails/commands/server.rb +++ b/railties/lib/rails/commands/server.rb @@ -38,15 +38,14 @@ module Rails end def start + ENV["RAILS_ENV"] = options[:environment] + puts "=> Booting #{ActiveSupport::Inflector.demodulize(server)}" - puts "=> Rails #{Rails.version} application starting on http://#{options[:Host]}:#{options[:Port]}" + puts "=> Rails #{Rails.version} application starting in #{Rails.env} on http://#{options[:Host]}:#{options[:Port]}" puts "=> Call with -d to detach" unless options[:daemonize] trap(:INT) { exit } puts "=> Ctrl-C to shutdown server" unless options[:daemonize] - ENV["RAILS_ENV"] = options[:environment] - RAILS_ENV.replace(options[:environment]) if defined?(RAILS_ENV) - super ensure puts 'Exiting' unless options[:daemonize] |