From 0088ceb6fac35cd0b0480f153a7c6e8772313037 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Mon, 23 Nov 2009 22:07:37 -0800 Subject: Set RAILS_ENV before loading config/environment --- railties/lib/rails/commands/console.rb | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'railties/lib/rails/commands') diff --git a/railties/lib/rails/commands/console.rb b/railties/lib/rails/commands/console.rb index 1ed2db8dc9..1a40ed92cf 100644 --- a/railties/lib/rails/commands/console.rb +++ b/railties/lib/rails/commands/console.rb @@ -4,6 +4,8 @@ require "irb/completion" module Rails class Console + ENVIRONMENTS = %w(production development test) + def self.start new.start end @@ -18,6 +20,10 @@ module Rails opt.parse!(ARGV) end + if env = ARGV.first + ENV['RAILS_ENV'] = ENVIRONMENTS.find { |e| e.index(env) } || env + end + require "#{Rails.root}/config/environment" require "rails/console_app" require "rails/console_sandbox" if options[:sandbox] @@ -33,15 +39,6 @@ module Rails end end - ENV['RAILS_ENV'] = - case ARGV.first - when "p" then "production" - when "d" then "development" - when "t" then "test" - else - ARGV.first || ENV['RAILS_ENV'] || 'development' - end - if options[:sandbox] puts "Loading #{ENV['RAILS_ENV']} environment in sandbox (Rails #{Rails.version})" puts "Any modifications you make will be rolled back on exit" @@ -51,4 +48,4 @@ module Rails IRB.start end end -end \ No newline at end of file +end -- cgit v1.2.3