Skip to content

Instantly share code, notes, and snippets.

@MyArtChannel
Created April 25, 2011 20:42
Show Gist options
  • Star 34 You must be signed in to star a gist
  • Fork 8 You must be signed in to fork a gist
  • Save MyArtChannel/941174 to your computer and use it in GitHub Desktop.
Save MyArtChannel/941174 to your computer and use it in GitHub Desktop.
Use Pry as IRB replacement in rails 3 console
# Add this to the end of your development.rb and add
#
# gem 'pry'
#
# to your Gemfile and run bundle to install.
silence_warnings do
begin
require 'pry'
IRB = Pry
rescue LoadError
end
end
@robbevan
Copy link

reload! definitely works for me, yes

@agibralter
Copy link

Hmmm, for some reason my models don't get reloaded... then there must be something weird in my app environment. Thanks @robbevan

@grosser
Copy link

grosser commented Oct 18, 2011

alias pryr="pry -r ./config/environment -r rails/console/app -r rails/console/helpers"

@dnszero
Copy link

dnszero commented Nov 30, 2011

@grosser FTW!

@npiv
Copy link

npiv commented Jan 30, 2012

much obliged grosser, that worked great for me. No messing with the actual project source

@sheerun
Copy link

sheerun commented Feb 5, 2012

I use following one-liner because it leaves irb command unchanged and bundle console runs whatever you have in Gemfile (eg. bundle console development). And use pry if you want repl without Gemfile.

echo "Pry.start || exit rescue LoadError" > ~/.irbrc

@quark-zju
Copy link

I use this in my zshrc:

pry () {
    if [ -e Gemfile.lock ] && [ -e ./config/environment.rb ] && grep -q pry Gemfile.lock
    then
        bundle exec pry -r ./config/environment "$@"
    else
        /usr/bin/pry "$@"
    fi
}

@l0b0
Copy link

l0b0 commented Mar 28, 2012

@grosser reload! doesn't work here using the alias. Any ideas?

@grosser
Copy link

grosser commented Mar 28, 2012

@l0b0 see where reload! is defined and include this too or see what else gets included to irb

@lfender6445
Copy link

@13k thanks works great

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment