diff options
author | Guillermo Iguaran <guilleiguaran@gmail.com> | 2017-05-13 19:32:39 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-13 19:32:39 -0500 |
commit | 630b65347af7298c2e33f0f3941cb074de8529dd (patch) | |
tree | db3556b3c40c598f5823f9035fa83b19499f91c5 /railties/lib/rails | |
parent | 23aa0a2bb551717f153ac75f24c017c43ab853f2 (diff) | |
parent | c776b6470875fd40885b181ff8467a2c2cc3ec70 (diff) | |
download | rails-630b65347af7298c2e33f0f3941cb074de8529dd.tar.gz rails-630b65347af7298c2e33f0f3941cb074de8529dd.tar.bz2 rails-630b65347af7298c2e33f0f3941cb074de8529dd.zip |
Merge pull request #29010 from y-yagi/fix_28988
Allow irb options to be passed from `rails console` command
Diffstat (limited to 'railties/lib/rails')
-rw-r--r-- | railties/lib/rails/commands/console/console_command.rb | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/railties/lib/rails/commands/console/console_command.rb b/railties/lib/rails/commands/console/console_command.rb index 62e3aa19df..ec58540923 100644 --- a/railties/lib/rails/commands/console/console_command.rb +++ b/railties/lib/rails/commands/console/console_command.rb @@ -73,14 +73,26 @@ module Rails class_option :environment, aliases: "-e", type: :string, desc: "Specifies the environment to run this console under (test/development/production)." + 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 + def perform extract_environment_option_from_argument # RAILS_ENV needs to be set before config/application is required. ENV["RAILS_ENV"] = options[:environment] - ARGV.clear # Clear ARGV so IRB doesn't freak. - require_application_and_environment! Rails::Console.start(Rails.application, options) end |