diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2009-11-23 22:07:37 -0800 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2009-11-23 22:07:37 -0800 |
commit | 0088ceb6fac35cd0b0480f153a7c6e8772313037 (patch) | |
tree | 1309386b711d539e0bcf677e86a0c1515705b4bb /railties/lib/rails/commands | |
parent | 59dbae145b939ca733b7fc9ed0205b01c3d6799c (diff) | |
download | rails-0088ceb6fac35cd0b0480f153a7c6e8772313037.tar.gz rails-0088ceb6fac35cd0b0480f153a7c6e8772313037.tar.bz2 rails-0088ceb6fac35cd0b0480f153a7c6e8772313037.zip |
Set RAILS_ENV before loading config/environment
Diffstat (limited to 'railties/lib/rails/commands')
-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 |