How do I get a list of all the tables defined for the database when using active record?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Call
ActiveRecord::ConnectionAdapters::SchemaStatements#tables. This method is undocumented in the MySQL adapter, but is documented in the PostgreSQL adapter. SQLite/SQLite3 also has the method implemented, but undocumented.See
activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb:21, as well as the implementations here:activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:412activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:615activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb:176