ShakaCode | ShakaCode Blog | Rails On Maui Blog | Rails | ReactJs | JavaScript | Webpack | Productivity |

My .pryrc for debugging and productivity


#1

I love pry!

Here’s my .pryrc

Gems I use for Pry:

  gem "pry"
  gem "pry-rails"
  gem "pry-byebug"
  gem "pry-stack_explorer"
  gem "pry-doc"
  gem "awesome_print"
  gem "binding_of_caller"

Commands for Help

Once you’ve installed you, can run:

Tip: Run help alias

Aliases
  !!!                Alias for `exit-program`
  !!@                Alias for `exit-all`
  $                  Alias for `show-source`
  ?                  Alias for `show-doc`
  @                  Alias for `whereami`
  bb                 Alias for `break`
  breakpoint         Alias for `break`
  cc                 Alias for `continue`
  clipit             Alias for `gist --clip`
  dd                 Alias for `down`
  ff                 Alias for `frame`
  file-mode          Alias for `shell-mode`
  fin                Alias for `finish`
  find-routes        Alias for `find-route`
  h                  Last 20 commands
  hG                 Commands matching expression ever used
  hg                 Up to 20 commands matching expression
  history            Alias for `hist`
  hr                 Hist -r <command number> to run a command
  nn                 Alias for `next`
  quit               Alias for `exit`
  quit-program       Alias for `exit-program`
  reload-method      Alias for `reload-code`
  show-method        Alias for `show-source`
  ss                 Alias for `step`
  uu                 Alias for `up`
  ww                 Alias for `whereami`

or run more_help

Helpful shortcuts:
hh  : hist -T 20       Last 20 commands
hg : hist -T 20 -G    Up to 20 commands matching expression
hG : hist -G          Commands matching expression ever used
hr : hist -r          hist -r <command number> to run a command

Samples variables
a_array  :  [1, 2, 3, 4, 5, 6]
a_hash   :  { hello: "world", free: "of charge" }

helper   : Access Rails helpers
app      : Access url_helpers

require "rails_helper"              : To include Factory Girl Syntax
include FactoryGirl::Syntax::Methods  : To include Factory Girl Syntax

or if you defined one...
require "pry_helper"

Sidekiq::Queue.new.clear              : To clear sidekiq
Sidekiq.redis { |r| puts r.flushall } : Another clear of sidekiq

Debugging Shortcuts
ss  :  step
nn  :  next
cc  :  continue
fin :  finish
uu  :  up
dd  :  down
ff  :  frame
bb  :  break
ww  :  whereami

Yak of the week! Ruby 2.4 Pathname empty? changed to look at file size!
Justin's Favorite Forum Posts -- Start Here
Favorite Rails and JavaScript debugging tips
#2

Here are a few more tips:

  1. I mostly use Pry rather than RubyMine because it’s way faster to get to the debugger. You can modify the Rails app without restarting.
  2. You must not run the Rails command within the context of foreman. If you’re using foreman to start Rails and other processes, you will need to either comment out the Rails process or run foreman like this: foreman start -f Procfile.dev -m webpack-client-bundle=1,webpack-server-bundle=1 where webpack-client-bundle and webpack-server-bundle are your processes to start.
  3. If you run puma by default, you might want to switch the application server for debugging so that you don’t have multiple threads going at once. Running rails s might do the trick.

Be sure to also see: