Skip to content

Instantly share code, notes, and snippets.

@estum
Created October 15, 2015 09:51
Show Gist options
  • Save estum/ad8ec4de92bc9efd68d1 to your computer and use it in GitHub Desktop.
Save estum/ad8ec4de92bc9efd68d1 to your computer and use it in GitHub Desktop.
Pry `show-tables` command to list tables for the current ActiveRecord connection.
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