Skip to content

Instantly share code, notes, and snippets.

@damon
Created June 23, 2010 01:45
Show Gist options
  • Save damon/449363 to your computer and use it in GitHub Desktop.
Save damon/449363 to your computer and use it in GitHub Desktop.
a couple of Object hacks in my .irbrc
class Object
def dbpeek
ActiveRecord::Base.connection.tables
end
def tblpeek(tbl=nil)
ActiveRecord::Base.connection.columns(tbl).each do |c|
puts "#{c.name}|#{c.type}|#{c.limit}"
end if tbl
nil
end
def dbschema
begin
ActiveRecord::Base.connection.select_value("select version from schema_info")
rescue
ActiveRecord::Base.connection.select_value("select version from schema_migrations")
end
end
def ml(*m)
result = []
m.each do |t|
result << methods.grep(/#{t}/)
end
result.flatten.uniq
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment