Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in SQL by (20.3k points)

I know that you can ask ActiveRecord to list tables in the console using:

ActiveRecord::Base.connection.tables

Is there a command that would list the columns in a given table?

1 Answer

0 votes
by (40.4k points)

The below code will list the column_names from a table:

Model.column_names

e.g. User.column_names

Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers

500 comments

94.1k users

Browse Categories

...