Class: Rails::Console
Relationships & Source Files | |
Namespace Children | |
Modules:
| |
Inherits: | Object |
Defined in: | railties/lib/rails/commands/console/console_command.rb |
Class Method Summary
- .new(app, options = {}) ⇒ Console constructor
- .start(*args)
Instance Attribute Summary
- #app readonly
- #console readonly
- #environment (also: #environment?) readonly
-
#environment?
readonly
Alias for #environment.
- #options readonly
- #sandbox? ⇒ Boolean readonly
Instance Method Summary
Constructor Details
.new(app, options = {}) ⇒ Console
# File 'railties/lib/rails/commands/console/console_command.rb', line 24
def initialize(app, = {}) @app = app @options = app.sandbox = sandbox? if sandbox? && app.config.disable_sandbox puts "Error: Unable to start console in sandbox mode as sandbox mode is disabled (config.disable_sandbox is true)." exit 1 end app.load_console @console = app.config.console || IRB if @console == IRB IRB::WorkSpace.prepend(BacktraceCleaner) end end
Class Method Details
.start(*args)
[ GitHub ]# File 'railties/lib/rails/commands/console/console_command.rb', line 18
def self.start(*args) new(*args).start end
Instance Attribute Details
#app (readonly)
[ GitHub ]# File 'railties/lib/rails/commands/console/console_command.rb', line 22
attr_reader :, :app, :console
#console (readonly)
[ GitHub ]# File 'railties/lib/rails/commands/console/console_command.rb', line 22
attr_reader :, :app, :console
#environment (readonly) Also known as: #environment?
[ GitHub ]# File 'railties/lib/rails/commands/console/console_command.rb', line 48
def environment [:environment] end
#environment? (readonly)
Alias for #environment.
# File 'railties/lib/rails/commands/console/console_command.rb', line 51
alias_method :environment?, :environment
#options (readonly)
[ GitHub ]
#sandbox? ⇒ Boolean
(readonly)
[ GitHub ]
# File 'railties/lib/rails/commands/console/console_command.rb', line 44
def sandbox? [:sandbox] end
Instance Method Details
#set_environment!
[ GitHub ]# File 'railties/lib/rails/commands/console/console_command.rb', line 53
def set_environment! Rails.env = environment end
#start
[ GitHub ]# File 'railties/lib/rails/commands/console/console_command.rb', line 57
def start set_environment! if environment? if sandbox? puts "Loading #{Rails.env} environment in sandbox (Rails #{Rails.version})" puts "Any modifications you make will be rolled back on exit" else puts "Loading #{Rails.env} environment (Rails #{Rails.version})" end if defined?(console::ExtendCommandBundle) console::ExtendCommandBundle.include(Rails::ConsoleMethods) end console.start end