diff options
Diffstat (limited to 'railties')
-rw-r--r-- | railties/lib/rails/commands/console.rb | 17 |
1 files changed, 7 insertions, 10 deletions
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 |