Report abuse

IRB.conf[:AUTO_INDENT] = true  

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

class Object
  def own_methods
    own_methods = self.methods - self.class.superclass.methods
    own_methods.sort.each{|n| printf("%s\n", n)}
    self.class.to_s + " object has " + own_methods.size.to_s + " methods"
  end
end  

def ri(*names)
  system(%{ri #{names.map {|name| name.to_s}.join(" ")}})
end

if rails_env = ENV['RAILS_ENV']
  def named_routes
    ActionController::Routing::Routes.named_routes.each {|name, r| printf("%-40s %s\n", name, r) }; nil
  end

  def routes
    puts ActionController::Routing::Routes.routes
  end

  IRB.conf[:IRB_RC] = Proc.new do 
    ActiveRecord::Base.logger = Logger.new(STDOUT)
    ActiveRecord::Base.instance_eval { alias :[] :find } 
  end

  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
end