rails c rails g model Model Database Column

Check Database Table Columns with rails g model in rails c

This article introduces how to check the contents (columns) of models (database tables) created with rails g model in the Ruby on Rails console (rails c).

Shou Arisaka
1 min read
Nov 23, 2025

This article introduces how to check the contents (columns) of models (database tables) created with rails g model in the Ruby on Rails console (rails c).

irb(main):011:0> Userinfo.columns.map(&:name)
=> ["id", "name", "created_at", "updated_at"]
irb(main):012:0> Userinfo.column_names
=> ["id", "name", "created_at", "updated_at"]

Check the files in `/db/migrate`

Check \db\schema.rb: This may be the most reliable method.

While there are methods to check in the console as shown above, checking the files in /db/migrate may be the most reliable.

Share this article

Shou Arisaka Nov 23, 2025

๐Ÿ”— Copy Links