Created
October 15, 2015 09:51
-
-
Save estum/ad8ec4de92bc9efd68d1 to your computer and use it in GitHub Desktop.
Pry `show-tables` command to list tables for the current ActiveRecord connection.
This file contains hidden or 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
Pry::Commands.create_command "show-tables" do | |
group "Rails" | |
description "List tables for the current ActiveRecord connection" | |
def options(opt) | |
opt.banner unindent <<-BANNER | |
Usage: show-tables | |
List tables for the current ActiveRecord connection | |
BANNER | |
end | |
def process | |
tables.each do |table| | |
output.puts(table) | |
end | |
end | |
private | |
def tables | |
ActiveRecord::Base.connection.tables | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment