1

I had an alias for reload! command in the rails console:

# ~/.irbrc

if defined? Rails
  def r
    reload!
  end
end

In rails v7.2 this no longer works:

>> r
(stackoverflow):1:in `<main>': undefined method `reload!' for main (NoMethodError)

    reload!
    ^^^^^^^

but reload! still works on its own:

>> reload!
Reloading...

How do I alias reload! with r?

0

1 Answer 1

3

The future proof way seems to be IRB extensions.

IRB::Command.register(:r, Rails::Console::Reloader)

The entire console integration was changed in Rails 7.2 and a lot of the exisiting functionality moved into rails/railties/lib/rails/commands/console /irb_console.rb.

Sign up to request clarification or add additional context in comments.

3 Comments

Interestingly there is no mention of this in the change notes for 7.2.
thank you, that works. i wonder why they had to make it an IRB::Command instead of IRB::HelperMethod which would make reload! a regular ruby method.
"If you don't know what to pick, go with commands first."?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.