.irbrc

If you want a really nice irb with autocompletion, a saved scrollback memory, and other fun stuff, try this:

codetitle. ~/.irbrc

require 'yaml'

def reset
  Dispatcher.reset_application!
end
  
IRB.conf[:AUTO_INDENT] = true
IRB.conf[:USE_READLINE] = true
IRB.conf[:LOAD_MODULES] = []  unless IRB.conf.key?(:LOAD_MODULES)
unless IRB.conf[:LOAD_MODULES].include?('irb/completion')
  IRB.conf[:LOAD_MODULES] << 'irb/completion'
end      

require 'irb/completion'
require 'irb/ext/save-history'
IRB.conf[:PROMPT_MODE] = :SIMPLE
IRB.conf[:SAVE_HISTORY] = 100
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-save-history"

def setzone
  TzTime.zone = TimeZone['Pacific Time (US & Canada)'] 
end

usage

Dump a formatted YAML output with one character

>> y user
>> puts user.to_yaml

Both lines will do the same thing, but the first is more fun!

Reset rails

>> reset

This will reload the rails classes so that you don’t have to quit the console to test your new changes. If you change something in config, you still need to quit.

Tab completion

Not sure what the method is? Hit tab to complete the method name.