It seems like a silly question, but anyway:
I have a model with lets say 10-12 fields (columns) added in different migrations.
When I write code now (model, view, tests) I want to have a list of the column names.
Is there a good way to do so? (other than going to the DB manually and getting the column names)
It seems like an action the developer does quite often, or is it just me
Simply use ActiveRecord::Base#column_names:
Model.column_names
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments