Fix inspect on Devise models
Have you wondered why User and other Devise models don't print properly in your console? Instead of nice pretty printed output, even if you're using a pretty printer, you still get a long, ugly, unreadable string.
Today I finally got fed up enough to do something about it, and here is the solution:
Chuck this into the bottom of your config/initializers/devise.rb
file and you're good to go. It removes the overriding of the inspect
method that is the culprit.
Devise::Models::Authenticatable.remove_method(:inspect)
But Obie, what about Chesterton's Fence!?!?!
My answer is that if you're paranoid about the possibility of inspect
being called by a logger while a plain-text password happens to be in scope, then by all means override the method instead of just removing it, but doing so is left as an exercise to the reader. (Hint: start overriding it and Github CoPilot will do the rest.)