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.

I'm sharing everything I learn while building a software company. Join my newsletter to receive advice and opportunities that I never post publicly. Or learn more about me?