diff options
Diffstat (limited to 'railties/lib/rails/commands/console.rb')
-rw-r--r-- | railties/lib/rails/commands/console.rb | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/railties/lib/rails/commands/console.rb b/railties/lib/rails/commands/console.rb index 37eb6d40ea..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.first - 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 |