Class: Rails::Command::ConsoleCommand

Inherits:
Base show all
Includes:
EnvironmentArgument
Defined in:
railties/lib/rails/commands/console/console_command.rb

Overview

:nodoc:

Instance Method Summary collapse

Methods included from ActiveSupport::Concern

#append_features, #class_methods, extended, #included, #prepend_features, #prepended

Methods inherited from Base

banner, base_name, command_name, default_command_root, desc, engine?, executable, exit_on_failure?, #help, hide_command!, inherited, namespace, perform, printing_commands, usage_path

Methods included from Actions

#load_generators, #load_tasks, #require_application!, #require_application_and_environment!, #require_environment!, #set_application_directory!

Constructor Details

#initialize(args = [], local_options = {}, config = {}) ⇒ ConsoleCommand

Returns a new instance of ConsoleCommand.


81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'railties/lib/rails/commands/console/console_command.rb', line 81

def initialize(args = [], local_options = {}, config = {})
  console_options = []

  # For the same behavior as OptionParser, leave only options after "--" in ARGV.
  termination = local_options.find_index("--")
  if termination
    console_options = local_options[termination + 1..-1]
    local_options = local_options[0...termination]
  end

  ARGV.replace(console_options)
  super(args, local_options, config)
end

Instance Method Details

#performObject


95
96
97
98
99
100
101
102
103
# File 'railties/lib/rails/commands/console/console_command.rb', line 95

def perform
  extract_environment_option_from_argument

  # RAILS_ENV needs to be set before config/application is required.
  ENV["RAILS_ENV"] = options[:environment]

  require_application_and_environment!
  Rails::Console.start(Rails.application, options)
end