Permalink
Browse files

Set RAILS_ENV before loading config/environment

  • Loading branch information...
1 parent 59dbae1 commit 0088ceb6fac35cd0b0480f153a7c6e8772313037 @jeremy jeremy committed Nov 24, 2009
Showing with 7 additions and 10 deletions.
  1. +7 −10 railties/lib/rails/commands/console.rb
@@ -4,6 +4,8 @@
module Rails
class Console
+ ENVIRONMENTS = %w(production development test)
+
def self.start
new.start
end
@@ -18,6 +20,10 @@ def start
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 @@ def start
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 @@ def start
IRB.start
end
end
-end
+end

0 comments on commit 0088ceb

Please sign in to comment.