Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Usage commands for Pry
load rails console w/ pry
========================
pry -r ./config/environment
help
cd Article
self
first
cd first
self
name
cd name
upcase
nesting
cd ..
jump-to 0
exit
ls
ls -h
ls -m (methods)
ls -mj (just class methods)
ls -M (instance methods)
ls -i (instance vars)
ls Array -M
show-doc Array#in_groups_of
show-doc all.in_groups_of
show-method all.in_groups_of
edit-method all.in_groups_of
.ls (system ls)
.cat Gemfile
DEBUGGING
=========
Article.first
word_count (one of controller action)
content (article attribute)
edit-method word_count
def word_count
words = content.scan(/\\w+/)
ADD --> binding.pry
words.size
end
words (can access vars now)
exit-all
------------------------------------
repl.rb (READ, EVALUATE, PRINT, LOOP)
--> loop { p eval gets }
gist-method s.each_line (make a gist of s file)
gem-cd mysql2
.pwd
.tree
def helo(name)
show-input
! (clear the input buffer)
def hello(name)
"Hello, #{name}
show-input
amend-line 2 "Hello, #{name}"
end
pry -r ./stack.rb (require any file like this)
stack = Stack.new
show-doc stack.each
cd stack
edit-method each
whereami (after clear screen)
Replace IRB in Rails Console w/ Pry
====================
in environments/development.rb -->
add -->
silence_warnings do
require 'pry'
IRB = Pry
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.