Skip to content

Instantly share code, notes, and snippets.

@bsbodden
Created February 9, 2013 21:28
Show Gist options
  • Save bsbodden/4747184 to your computer and use it in GitHub Desktop.
Save bsbodden/4747184 to your computer and use it in GitHub Desktop.
My .irbrc file
require 'rbconfig'
Config = RbConfig
if defined?(Rails)
Dir.glob("#{Rails.root}/app/models/**/*.rb").each { |file| require file }
end
def clear
system 'clear'
nil
end
begin
require 'hirb'
Hirb.enable
extend Hirb::Console
def render(table)
Hirb::Helpers::AutoTable.render(table)
end
rescue Exception => e
# no Hirb for you!
end
class Class
def extend?(klass)
not superclass.nil? and ( superclass == klass or superclass.extend? klass )
end
end
def models
Module.constants.select do |constant_name|
constant = eval constant_name.to_s
if not constant.nil? and constant.is_a? Class and constant.extend? ActiveRecord::Base
constant
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment