Skip to content

Commit

Permalink
Merge pull request rails#52996 from pbhogan/console_reload_fix
Browse files Browse the repository at this point in the history
Add reload! as a IRB::HelperMethod so it can be combined with other calls in a single statement. Fixes rails#52982
  • Loading branch information
byroot authored Oct 1, 2024
2 parents 8eebddd + c695694 commit 87e7ad6
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions railties/lib/rails/commands/console/irb_console.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,16 @@ def execute(create = false)
end
end

class Reloader < IRB::Command::Base
class ReloadHelper < RailsHelperBase
description "Reloads the Rails application."

def execute
puts "Reloading..."
Rails.application.reloader.reload!
end
end

class ReloadCommand < IRB::Command::Base
include ConsoleMethods

category "Rails console"
Expand All @@ -67,7 +76,8 @@ def execute(*)
IRB::HelperMethod.register(:controller, ControllerInstance)
IRB::HelperMethod.register(:new_session, NewSession)
IRB::HelperMethod.register(:app, AppInstance)
IRB::Command.register(:reload!, Reloader)
IRB::HelperMethod.register(:reload!, ReloadHelper)
IRB::Command.register(:reload!, ReloadCommand)

class IRBConsole
def initialize(app)
Expand Down

0 comments on commit 87e7ad6

Please sign in to comment.