How to debug Rails application?
There are several gems to debug your Ruby code:
debugger - A fork of ruby-debug that works on Ruby 1.9.3
1 2 3
pry-debugger - Using debugger within pry
1 2 3
1 2 3 4
NOTE: You won’t be able to use those words as params while debugging
1 2 3 4 5 6 7 8 9
Now start your rails server (rails s) and visit your controller url: http://localhost:3000/home. The pry debugger console will appear in your terminal. You can use all pry functionality inside your application in addition to predefined aliases(next, step, continue, etc.).
Other useful commands:
- help - show a list of available commands
- exit - exit a context with a user provided value
- whereami - describe the current location (alternative: $)
- break - set a breakpoint
- wtf -v - see the entire backtrace