SlideShare uma empresa Scribd logo
1 de 22
Debugging Rails 3 Applications




            Nathan Broadbent
            Onboard Coding Ltd.

       https://twitter.com/ndbroadbent
       http://github.com/ndbroadbent
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
Debugging Ruby
debugger
●   Use 'debugger' gem for Ruby 1.9.2 and 1.9.3
●   commands
    –   next
    –   step
    –   list
    –   continue
    –   break
awesome_print
●   Ruby library that pretty prints Ruby objects in
    full color, exposing their internal structure with
    proper indentation.
Pry Overview
●   Powerful alternative to IRB / debugger
●   Source code / documentation browsing
●   Syntax highlighting
●   Configure via ~/.pryrc
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'
    –   Adds docs for Ruby
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. When file is
        closed, it will be executed
●   edit-method
    –   Jump to a place in your project, handy for opening
        files from gems
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 inspection for all stack frames
    (with syntax highlighting)
●   Local and instance variable inspection
●   Live REPL on every stack frame
    –   REPL = read, eval, print, loop
Errbit
open source, self-hosted error catcher
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.
Debugging
 JavaScript
with Chrome
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()
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
    started to occur


git bisect start
git bisect good e401315
git bisect bad master
git bisect run rspec spec/models/book_spec.rb
... wait a bit ...
5243cafebabe is the last bad commit
Questions or
Comments?

Mais conteúdo relacionado

Mais procurados

Getting Started with (Distributed) Version Control
Getting Started with (Distributed) Version ControlGetting Started with (Distributed) Version Control
Getting Started with (Distributed) Version Control
John Paulett
 
Ruby projects of interest for DevOps
Ruby projects of interest for DevOpsRuby projects of interest for DevOps
Ruby projects of interest for DevOps
Ricardo Sanchez
 
20140419 oedo rubykaigi04
20140419 oedo rubykaigi0420140419 oedo rubykaigi04
20140419 oedo rubykaigi04
Hiroshi SHIBATA
 
20140425 ruby conftaiwan2014
20140425 ruby conftaiwan201420140425 ruby conftaiwan2014
20140425 ruby conftaiwan2014
Hiroshi SHIBATA
 

Mais procurados (20)

The BlackBox Project: Safely store secrets in Git/Mercurial (originally for P...
The BlackBox Project: Safely store secrets in Git/Mercurial (originally for P...The BlackBox Project: Safely store secrets in Git/Mercurial (originally for P...
The BlackBox Project: Safely store secrets in Git/Mercurial (originally for P...
 
20140918 ruby kaigi2014
20140918 ruby kaigi201420140918 ruby kaigi2014
20140918 ruby kaigi2014
 
Do it Yourself Testing
Do it Yourself TestingDo it Yourself Testing
Do it Yourself Testing
 
Getting Started with (Distributed) Version Control
Getting Started with (Distributed) Version ControlGetting Started with (Distributed) Version Control
Getting Started with (Distributed) Version Control
 
Ruby projects of interest for DevOps
Ruby projects of interest for DevOpsRuby projects of interest for DevOps
Ruby projects of interest for DevOps
 
My talk on Piter Py 2016
My talk on Piter Py 2016My talk on Piter Py 2016
My talk on Piter Py 2016
 
Deconstruct 2017: All programmers MUST learn C and Assembly
Deconstruct 2017: All programmers MUST learn C and AssemblyDeconstruct 2017: All programmers MUST learn C and Assembly
Deconstruct 2017: All programmers MUST learn C and Assembly
 
CRaSH the shell for the JVM
CRaSH the shell for the JVMCRaSH the shell for the JVM
CRaSH the shell for the JVM
 
How to develop the Standard Libraries of Ruby?
How to develop the Standard Libraries of Ruby?How to develop the Standard Libraries of Ruby?
How to develop the Standard Libraries of Ruby?
 
CRaSH the shell for the Java Virtual Machine
CRaSH the shell for the Java Virtual MachineCRaSH the shell for the Java Virtual Machine
CRaSH the shell for the Java Virtual Machine
 
Brief introduction to kselftest
Brief introduction to kselftestBrief introduction to kselftest
Brief introduction to kselftest
 
Composer Helpdesk
Composer HelpdeskComposer Helpdesk
Composer Helpdesk
 
20140419 oedo rubykaigi04
20140419 oedo rubykaigi0420140419 oedo rubykaigi04
20140419 oedo rubykaigi04
 
CPAN Training
CPAN TrainingCPAN Training
CPAN Training
 
20140925 rails pacific
20140925 rails pacific20140925 rails pacific
20140925 rails pacific
 
20140425 ruby conftaiwan2014
20140425 ruby conftaiwan201420140425 ruby conftaiwan2014
20140425 ruby conftaiwan2014
 
Slack Bots in Ruby
Slack Bots in RubySlack Bots in Ruby
Slack Bots in Ruby
 
The Parenscript Common Lisp to JavaScript compiler
The Parenscript Common Lisp to JavaScript compilerThe Parenscript Common Lisp to JavaScript compiler
The Parenscript Common Lisp to JavaScript compiler
 
Npm: beyond 'npm i'
Npm: beyond 'npm i'Npm: beyond 'npm i'
Npm: beyond 'npm i'
 
The details of CI/CD environment for Ruby
The details of CI/CD environment for RubyThe details of CI/CD environment for Ruby
The details of CI/CD environment for Ruby
 

Semelhante a Debugging Rails 3 Applications

Ruby/rails performance and profiling
Ruby/rails performance and profilingRuby/rails performance and profiling
Ruby/rails performance and profiling
Danny Guinther
 
Writing a Ruby Gem for beginners
Writing a Ruby Gem for beginnersWriting a Ruby Gem for beginners
Writing a Ruby Gem for beginners
ConFoo
 
Behat Workshop at WeLovePHP
Behat Workshop at WeLovePHPBehat Workshop at WeLovePHP
Behat Workshop at WeLovePHP
Marcos Quesada
 
Ruby on rails探索
Ruby on rails探索Ruby on rails探索
Ruby on rails探索
Mu Chun Wang
 
これからのPerlプロダクトのかたち(YAPC::Asia 2013)
これからのPerlプロダクトのかたち(YAPC::Asia 2013)これからのPerlプロダクトのかたち(YAPC::Asia 2013)
これからのPerlプロダクトのかたち(YAPC::Asia 2013)
goccy
 

Semelhante a Debugging Rails 3 Applications (20)

Go at Skroutz
Go at SkroutzGo at Skroutz
Go at Skroutz
 
Ruby/rails performance and profiling
Ruby/rails performance and profilingRuby/rails performance and profiling
Ruby/rails performance and profiling
 
Middleware as Code with mruby
Middleware as Code with mrubyMiddleware as Code with mruby
Middleware as Code with mruby
 
Concurrency in ruby
Concurrency in rubyConcurrency in ruby
Concurrency in ruby
 
Writing a Ruby Gem for beginners
Writing a Ruby Gem for beginnersWriting a Ruby Gem for beginners
Writing a Ruby Gem for beginners
 
Exploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQLExploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQL
 
PDF Ruby on Rails 3 Day BC
 PDF Ruby on Rails 3 Day BC PDF Ruby on Rails 3 Day BC
PDF Ruby on Rails 3 Day BC
 
Behat Workshop at WeLovePHP
Behat Workshop at WeLovePHPBehat Workshop at WeLovePHP
Behat Workshop at WeLovePHP
 
Ruby formatters 2019
Ruby formatters 2019Ruby formatters 2019
Ruby formatters 2019
 
Road to sbt 1.0 paved with server
Road to sbt 1.0   paved with serverRoad to sbt 1.0   paved with server
Road to sbt 1.0 paved with server
 
JS Fest 2018. Алексей Волков. Полезные инструменты для JS разработки
JS Fest 2018. Алексей Волков. Полезные инструменты для JS разработкиJS Fest 2018. Алексей Волков. Полезные инструменты для JS разработки
JS Fest 2018. Алексей Волков. Полезные инструменты для JS разработки
 
Full stack development
Full stack developmentFull stack development
Full stack development
 
Grooscript greach
Grooscript greachGrooscript greach
Grooscript greach
 
rubyonrails
rubyonrailsrubyonrails
rubyonrails
 
rubyonrails
rubyonrailsrubyonrails
rubyonrails
 
Debugging rails
Debugging railsDebugging rails
Debugging rails
 
Ruby formatters
Ruby formattersRuby formatters
Ruby formatters
 
Montreal.rb ruby debugging basics - march 20th 2012
Montreal.rb   ruby debugging basics - march 20th 2012Montreal.rb   ruby debugging basics - march 20th 2012
Montreal.rb ruby debugging basics - march 20th 2012
 
Ruby on rails探索
Ruby on rails探索Ruby on rails探索
Ruby on rails探索
 
これからのPerlプロダクトのかたち(YAPC::Asia 2013)
これからのPerlプロダクトのかたち(YAPC::Asia 2013)これからのPerlプロダクトのかたち(YAPC::Asia 2013)
これからのPerlプロダクトのかたち(YAPC::Asia 2013)
 

Último

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Último (20)

Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 

Debugging Rails 3 Applications

  • 1. Debugging Rails 3 Applications Nathan Broadbent Onboard Coding Ltd. https://twitter.com/ndbroadbent http://github.com/ndbroadbent
  • 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
  • 4. debugger ● Use 'debugger' gem for Ruby 1.9.2 and 1.9.3 ● commands – next – step – list – continue – break
  • 5. awesome_print ● Ruby library that pretty prints Ruby objects in full color, exposing their internal structure with proper indentation.
  • 6. Pry Overview ● Powerful alternative to IRB / debugger ● Source code / documentation browsing ● Syntax highlighting ● Configure via ~/.pryrc
  • 7. Configure Pry ● simple ~/.pryrc – show Rails/Ruby version in prompt – add awesome_print gem
  • 8. Use Pry with Rails ● gem 'pry-rails' ● gem 'pry-debugger' – Adds step, next, continue, ... commands ● gem 'pry-doc' – Adds docs for Ruby
  • 9. Pry Commands ● show-method ● show-doc – show-doc Array#join ● ls ● cd – cd Array; show-doc join
  • 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. Learn more about Pry at http://pryrepl.org/
  • 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
  • 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.
  • 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()
  • 20. git blame ● Find out which commit changed this line ● Helps to understand the reasoning behind the change
  • 21. git bisect ● Binary search for commit history ● Find out exactly when a test started failing, or when an error started to occur git bisect start git bisect good e401315 git bisect bad master git bisect run rspec spec/models/book_spec.rb ... wait a bit ... 5243cafebabe is the last bad commit