Skip to content
Github 💻𝕏Linkedin 🔗

How to debug rails from console with prepend 💎

Code, Ruby, Rails1 min read

How to debug from rails from the console

Imagine you have this

class Dog
def speak
"woof"
end
end
module LoudDog
def speak
"WOOF!!!"
end
end
Dog.prepend(LoudDog)
Dog.new.speak
# => "WOOF!!!"

Boom — speak is overridden!

Similarly you can do this

module MyDebugPatch
def find_virtual_account
puts "🔍 Overridden find_virtual_account called"
super
end
end
Collection::OrderServices::CreateOrder.prepend(MyDebugPatch)