Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Debugging Rails 3 Applications            Nathan Broadbent            Onboard Coding Ltd.       https://twitter.com/ndbroa...
Topics●   Debugging Ruby    –   debugger, awesome_print, pry●   Debugging Rails errors    –   better_errors, Errbit●   Deb...
Debugging Ruby
debugger●   Use debugger gem for Ruby 1.9.2 and 1.9.3●   commands    –   next    –   step    –   list    –   continue    –...
awesome_print●   Ruby library that pretty prints Ruby objects in    full color, exposing their internal structure with    ...
Pry Overview●   Powerful alternative to IRB / debugger●   Source code / documentation browsing●   Syntax highlighting●   C...
Configure Pry●   simple ~/.pryrc    –   show Rails/Ruby version in prompt    –   add awesome_print gem
Use Pry with Rails●   gem pry-rails●   gem pry-debugger    –   Adds step, next, continue, ... commands●   gem pry-doc    –...
Pry Commands●   show-method●   show-doc    –    show-doc Array#join●   ls●   cd    –    cd Array; show-doc join
Pry Shell Integration●   Open file in editor, run rake task, etc.●   edit    –   prepare a block code from your editor. Wh...
Learn more about Pry at  http://pryrepl.org/
Debugging  Rails
better_errors
better_errors●   Replaces the standard Rails error page with a    much better and more useful error page●   Source code in...
Errbitopen source, self-hosted error catcher
Errbit            open source, self-hosted error catcher●   Open source alternative to Airbrake service●   Catches Ruby an...
Debugging JavaScriptwith Chrome
Chrome Console Overview●   Breakpoints    –   Set manually, or with a debugger statement    –   Pause on All/Uncaught Exce...
Debugging with
git blame●   Find out which commit changed this line●   Helps to understand the reasoning behind the    change
git bisect●    Binary search for commit history●    Find out exactly when a test started failing, or when an error    star...
Questions orComments?
Upcoming SlideShare
Loading in …5
×

Debugging Rails 3 Applications

2,366 views

Published on

Published in: Technology
  • Be the first to comment

Debugging Rails 3 Applications

  1. 1. Debugging Rails 3 Applications Nathan Broadbent Onboard Coding Ltd. https://twitter.com/ndbroadbent http://github.com/ndbroadbent
  2. 2. Topics● Debugging Ruby – debugger, awesome_print, pry● Debugging Rails errors – better_errors, Errbit● Debugging JavaScript with Chrome – Chrome Console, breakpoints, AJAX errors● Debugging with Git – git blame, git bisect
  3. 3. Debugging Ruby
  4. 4. debugger● Use debugger gem for Ruby 1.9.2 and 1.9.3● commands – next – step – list – continue – break
  5. 5. awesome_print● Ruby library that pretty prints Ruby objects in full color, exposing their internal structure with proper indentation.
  6. 6. Pry Overview● Powerful alternative to IRB / debugger● Source code / documentation browsing● Syntax highlighting● Configure via ~/.pryrc
  7. 7. Configure Pry● simple ~/.pryrc – show Rails/Ruby version in prompt – add awesome_print gem
  8. 8. Use Pry with Rails● gem pry-rails● gem pry-debugger – Adds step, next, continue, ... commands● gem pry-doc – Adds docs for Ruby
  9. 9. Pry Commands● show-method● show-doc – show-doc Array#join● ls● cd – cd Array; show-doc join
  10. 10. Pry Shell Integration● Open file in editor, run rake task, etc.● edit – prepare a block code from your editor. When file is closed, it will be executed● edit-method – Jump to a place in your project, handy for opening files from gems
  11. 11. Learn more about Pry at http://pryrepl.org/
  12. 12. Debugging Rails
  13. 13. better_errors
  14. 14. better_errors● Replaces the standard Rails error page with a much better and more useful error page● Source code inspection for all stack frames (with syntax highlighting)● Local and instance variable inspection● Live REPL on every stack frame – REPL = read, eval, print, loop
  15. 15. Errbitopen source, self-hosted error catcher
  16. 16. Errbit open source, self-hosted error catcher● Open source alternative to Airbrake service● Catches Ruby and JavaScript errors● Notify on 1st, 10th, 50th, 100th error – Email, SMS, Campfire, IRC● Issue tracker integration – GitHub, Pivotal, Redmine, Gitlab, etc.● Source code integration GitHub, Bitbucket, Gitlab etc.
  17. 17. Debugging JavaScriptwith Chrome
  18. 18. Chrome Console Overview● Breakpoints – Set manually, or with a debugger statement – Pause on All/Uncaught Exceptions – Break on events ● DOM Mutation ● XHR ● Event Listeners● console.log() – console.log(multiple, params, allowed)● console.trace()
  19. 19. Debugging with
  20. 20. git blame● Find out which commit changed this line● Helps to understand the reasoning behind the change
  21. 21. git bisect● Binary search for commit history● Find out exactly when a test started failing, or when an error started to occurgit bisect startgit bisect good e401315git bisect bad mastergit bisect run rspec spec/models/book_spec.rb... wait a bit ...5243cafebabe is the last bad commit
  22. 22. Questions orComments?

×