diff options
Diffstat (limited to 'railties/lib/rails/commands/console.rb')
-rw-r--r-- | railties/lib/rails/commands/console.rb | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/railties/lib/rails/commands/console.rb b/railties/lib/rails/commands/console.rb index aef7600fbd..35a9072f51 100644 --- a/railties/lib/rails/commands/console.rb +++ b/railties/lib/rails/commands/console.rb @@ -24,11 +24,20 @@ module Rails if arguments.first && arguments.first[0] != '-' env = arguments.first - options[:environment] = %w(production development test).detect {|e| e =~ /^#{env}/} || env + if available_environments.include? env + options[:environment] = env + else + options[:environment] = %w(production development test).detect {|e| e =~ /^#{env}/} || env + end end options end + + private + def available_environments + Dir[Rails.root.join('config', 'environments', '*.rb')].map { |fname| File.basename(fname, '.*') } + end end attr_reader :options, :app, :console |