require'rubygems'require'irb/completion'require'pp'require'what_methods'unless(IRB.conf[:LOAD_MODULES]||[]).join =~/config\/environment/require'active_support'require'map_by_method'# require 'guessmethod'
end# IRB.conf[:AUTO_INDENT]=true
classObject# Return a list of methods defined locally for a particular object. Useful
# for seeing what it does whilst losing all the guff that's implemented
# by its parents (eg Object).
deflocal_methods(obj =self)(obj.methods - obj.class.superclass.instance_methods).sort
endend# From http://www.clarkware.com/cgi/blosxom/2007/09/03#ConsoleFindShortcut
# Creates shortcut methods for finding models.
defdefine_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)endendendend# Called when the irb session is ready, after
# the Rails goodies used above have been loaded.
# users(1) => User.find(1)
IRB.conf[:IRB_RC]=Proc.new{define_model_find_shortcuts }