ActiveRecord: List columns in table from console

Andrew picture Andrew · Apr 7, 2011 · Viewed 81.4k times · Source

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

ActiveRecord::Base.connection.tables

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

Answer

Pravin picture Pravin · Apr 7, 2011

This will list the column_names from a table

Model.column_names
e.g. User.column_names