My Pry customizations for Rails console
I’m using Pry for my Rails console, I have defined the following alias in my ~/.zshrc
to start the rails console using Pry:
alias sc='./script/console --irb=pry'
The .pryrc
file is analogous to the .irbrc
file for IRB. You can use the .pryrc
file to customize Pry.
Below is my ~/.pryrc
file:
- The first line configure SublimeText 3 as Pry’s editor
- The methods
unbundled_require
andload_gem
allows me to load an installed gem that is not included in the current project’s Gemfile. In my case I’m loading the awesome_print gem (line 45) to pretty prints Ruby objects in full color exposing their internal structure with proper indentation - And then depending on the current Rails version, I configure the Rails logger (Rails 2) or the ActiveRecord logger (Rails 3) to use the
STDOUT
, in order to print the SQL statements to console.
This is how it looks my Rails console with these customizations: