- ls classname - shows methods
- _ - last value output
- ? classname.methodname - shows doc for method
- $ classname.methodname - shows source for method
- cat filename - output file
- file - last file touched
- wtf? - show backtrace for last error
- edit classname.methodname - opens in editor
- edit –ex - edit where most recent exception happened
- binding.pry - add into your app code to do a break point
- . - run rest of line as a shell command
- ; - put at end of line to not show return value, like if you only want output, or if you get back a huge object
Debugging
- play -l linenum - execute the code on a certain line
- cd varname - changes the value of
self
- cd .. - go out a level
- whereami - where did the debugger stop
- ls - shows methods, instance variables, and locals
pry-debugger
- step - step into method
- next
- continue
pry-rescue
break on unhandled exception
- cd-cause - go to where exception thrown
- try-again - replays Rails request
pry-stack_explorer
- show-stack — shows stack trace
- up, down — move up and down the stack
pry-clipboard
- copy-history — copies a command history entry
Videos
Ruby’s dynamic nature allows this kind of real-time introspection and changes