Created
June 23, 2010 01:45
-
-
Save damon/449363 to your computer and use it in GitHub Desktop.
a couple of Object hacks in my .irbrc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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