Here’s how to retrieve information about application tables in Rails, demonstrated from the Rails console (rails console or rails c):

Retrieve all application table names

irb(main):001:0> ActiveRecord::Base.connection.tables.reject { |table| table == 'ar_internal_metadata' || table == 'schema_migrations' }
=> ["customers", "orders", "products"]

Retrieve all table column names

irb(main):003:0> ActiveRecord::Base.connection.columns("customers").map(&:name)
=> ["id", "first_name", "last_name", "street", "city", "state", "postal_code", "country", "phone", "email", "created_at", "updated_at"]

Retrieve all ActiveRecord models

irb(main):004:0> ApplicationRecord.descendants
=> []
irb(main):005:0> Rails.application.eager_load!
=> true
irb(main):006:0> ApplicationRecord.descendants
=> [Customer(etc.), Order(etc.), Product(etc.)]

The first call to ApplicationRecord.descendants returns no results; this is because the application needs to be loaded first with: Rails.application.eager_load!.