Skip to content

Instantly share code, notes, and snippets.

@markmcdonald51
Created August 29, 2009 17:05
Show Gist options
  • Save markmcdonald51/177577 to your computer and use it in GitHub Desktop.
Save markmcdonald51/177577 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'irb/completion'
require 'map_by_method'
require 'what_methods'
require 'pp'
require 'hirb'
require 'irb/completion'
require 'irb/ext/save-history'
# Tell irb how much it should remember and where
# to save it's history
IRB.conf[:SAVE_HISTORY] = 100
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-save-history"
# Simple prompt
IRB.conf[:PROMPT_MODE] = :SIMPLE
# Auto indent code
IRB.conf[:AUTO_INDENT] = true
# This is only done when using the Rails console
if rails_env = ENV['RAILS_ENV']
Hirb::View.enable
# Setup a Rails specific prompt
rails_root = File.basename(Dir.pwd)
IRB.conf[:PROMPT] ||= {}
IRB.conf[:PROMPT][:RAILS] = {
:PROMPT_I => "#{rails_root}> ",
:PROMPT_S => "#{rails_root}* ",
:PROMPT_C => "#{rails_root}? ",
:RETURN => "=> %s\n"
}
IRB.conf[:PROMPT_MODE] = :RAILS
# This is only done when the irb session and
# rails are fully loaded (from Mike Clark)
IRB.conf[:IRB_RC] = Proc.new do
# Log ActiveRecord calls to standard out
ActiveRecord::Base.logger = Logger.new(STDOUT)
# Setup a [] alias for find so you can say:
# Post[1] instead of Post.find(1)
ActiveRecord::Base.instance_eval { alias :[] :find }
# Require and mixin the SuppressValidations gem
# (gem install polly-suppress_validations)
require "suppress_validations"
include SuppressValidations
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment