List column names for a table in Rails 5

October 11, 2018

I find myself needing to list column names quite often, but I can never remember the exact syntax. Use ModelName.column_names to get the column names of a particular table from your Rails console. For example:

rails c

The more you know.