rails/railties/lib
Edouard CHIN e60dd826c0 Don't output the whole Rails::Railtie object
- ### Summary

  The terminal output on a Rails application running ruby 3 will be
  cluttered with thousands of lines if one inadventarly call a
  unexisting method.
  This happen in various places (IntegrationTest, when running a db
  migration ...).
  This is related to a change in ruby 3 when a NoMethodError is
  raised.

  ### Simple reproduction

  ```
  class A
    def initialize(session)
      @a = session
    end
  end

  test = A.new("*" * 36)
  test.dsad # undefined method `dsad' for #<A:0x00007f847d8494b0 @a="************************************"> (NoMethodError)
  # Note that the "#<A:0x00007f847d8494b0 @a="************************************">" part
  # is 65 chars long.

  test = test = A.new("*" * 37)
  test.dsad # undefined method `dsad' for #<A:0x00007fa8c38299c0> (NoMethodError)
  ```

  On Ruby < 3, the NoMethodError message (everything starting from the
  "#" char) could only be 65 characters long. If it was above that
  ruby would only output the name of the class and its address.

  On Ruby >= 3, that limitation has been removed and the message can
  be any length long.

  ### On Rails

  Anytime a method is called on a object that holds the entire
  Rails::Application, the terminal would output the entire application
  which is annoying be can be dangerous because it will leak
  everything containing the credentials (stored inside the Application
  object).
2022-02-28 20:27:07 +01:00
..
minitest Add Oxford commas [ci-skip] 2022-02-21 11:11:11 -06:00
rails Don't output the whole Rails::Railtie object 2022-02-28 20:27:07 +01:00
rails.rb Delay loading Zeitwerk 2022-01-05 12:59:49 +01:00