diff options
Diffstat (limited to 'railties/lib/rails/commands/dbconsole.rb')
-rw-r--r-- | railties/lib/rails/commands/dbconsole.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/railties/lib/rails/commands/dbconsole.rb b/railties/lib/rails/commands/dbconsole.rb index 77c3404343..b836a17a49 100644 --- a/railties/lib/rails/commands/dbconsole.rb +++ b/railties/lib/rails/commands/dbconsole.rb @@ -34,7 +34,6 @@ module Rails abort opt.to_s unless (0..1).include?(ARGV.size) end - env = ARGV.first || ENV['RAILS_ENV'] || 'development' unless config = YAML::load(ERB.new(IO.read("#{@app.root}/config/database.yml")).result)[env] abort "No database is configured for the environment '#{env}'" end @@ -97,4 +96,9 @@ module Rails end end end +end + +# Has to set the RAILS_ENV before config/application is required +if ARGV.first && !ARGV.first.index("-") && env = ARGV.first + ENV['RAILS_ENV'] = %w(production development test).find { |e| e.index(env) } || env end
\ No newline at end of file |