ARGV.concat [ "--readline", "--prompt-mode", "simple" ]
require 'rubygems'
# for Bash like Tab completion
require 'irb/completion'
require 'irb/ext/save-history'
# from http://wiki.rubygarden.org/Ruby/page/show/Irb/TipsAndTricks
IRB.conf[:SAVE_HISTORY] = 1000
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb-save-history"
# call ri from within irb
def ri(*names)
system(%{ri #{names.map {|name| name.to_s}.join(" ")}})
end
# from http://clarkware.com/cgi/blosxom/2007/09/03#ConsoleFindShortcut
# Creates shortcut methods for finding models.
def define_model_find_shortcuts
model_files = Dir.glob("app/models/**/*.rb")
table_names = model_files.map { |f| File.basename(f).split('.')[0..-2].join }
table_names.each do |table_name|
Object.instance_eval do
define_method(table_name) do |*args|
table_name.camelize.constantize.send(:find, *args)
end
end
end
end
# Called when the irb session is ready, after
# the Rails goodies used above have been loaded.
IRB.conf[:IRB_RC] = Proc.new { define_model_find_shortcuts }