debugging rails 3 applications

Download Debugging Rails 3 Applications

If you can't read please download the document

Upload: nathan-broadbent

Post on 16-Apr-2017

2.350 views

Category:

Technology


4 download

TRANSCRIPT

Debugging Rails 3 Applications

Nathan BroadbentOnboard Coding Ltd.

https://twitter.com/ndbroadbenthttp://github.com/ndbroadbent

Topics

Debugging Rubydebugger, awesome_print, pry

Debugging Rails errorsbetter_errors, Errbit

Debugging JavaScript with ChromeChrome Console, breakpoints, AJAX errors

Debugging with Gitgit blame, git bisect

Debugging Ruby

debugger

Use 'debugger' gem for Ruby 1.9.2 and 1.9.3

commandsnext

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 ~/.pryrcshow 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-docshow-doc Array#join

ls

cdcd Array; show-doc join

Pry Shell Integration

Open file in editor, run rake task, etc.

editprepare a block code from your editor. When file is closed, it will be executed

edit-methodJump 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 frameREPL = 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 errorEmail, SMS, Campfire, IRC

Issue tracker integrationGitHub, Pivotal, Redmine, Gitlab, etc.

Source code integrationGitHub, Bitbucket, Gitlab etc.

Debugging JavaScript
with Chrome

Chrome Console Overview

BreakpointsSet manually, or with a debugger statement

Pause on All/Uncaught Exceptions

Break on eventsDOM 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 startgit bisect good e401315git bisect bad mastergit bisect run rspec spec/models/book_spec.rb... wait a bit ...5243cafebabe is the last bad commit

Questions or
Comments?