[Rails] Easy way to check columns

rails c

Open the console with.

User.column_names

Check the column with. Then, as shown below, it is possible to acquire and confirm only the column name currently being created without acquiring other unnecessary information.

[1] pry(main)> User.column_names
=> ["id",
 "email",
 "encrypted_password",
 "reset_password_token",
 "reset_password_sent_at",
 "remember_created_at",
 "created_at",
 "updated_at"]

By the way, the same confirmation can be done with User.columns.map (&: name).

[2] pry(main)> User.columns.map(&:name)
=> ["id",
 "email",
 "encrypted_password",
 "reset_password_token",
 "reset_password_sent_at",
 "remember_created_at",
 "created_at",
 "updated_at"]

However, since the description is long in this case, it seems better to check with User column_names ◯

Recommended Posts

[Rails] Easy way to check columns
Easy way to check method / field list in Java REPL
Easy way to set iOS app icon
Easy way to create JSP custom tags
Easy way to create an implementation of java.util.stream.Stream
One way to redirect_to with parameters in rails
Super easy way to use enum with JSP
How to check Rails commands in the terminal
Easy to display hello world with Rails + Docker
How to write Rails
Introducing CircleCI to Rails
Adding columns in Rails
Introducing Bootstrap to Rails 5
Introduce Vue.js to Rails
How to uninstall Rails
[Rails / Uniqueness constraint] How to check model validation on the console / Uniqueness constraint for multiple columns
[Linux] Easy commentary! How to check and change permissions
Easy to maintain FizzBuzz
What to check when rails db: migration does not pass
Super easy in 2 steps! How to install devise! !! (rails 5 version)
[rails] How to post images
[AWS] How to check logs
[Rails] How to use enum
Easy to create Processing library
[Rails] How to install devise
[Rails] How to use enum
How to read rails routes
How to use rails join
[Rails] Add column to devise
How to terminate rails server
How to write Rails validation
How to write Rails seed
[Rails] How to use validation
[Rails] How to disable turbolinks
Pass parameters to Rails link_to
How to check JSF version
[Rails] How to use authenticate_user!
[Rails] How to use "kaminari"
[Rails] How to implement scraping
[Rails] How to make seed
How to write Rails routing
[Rails] How to install simple_calendar
Easy to use array.map (&: method)
[Rails] How to install reCAPTCHA
Introduced gRPC client to rails
Introduction to RSpec-Everyday Rails Summary-
[Rails] How to use Scope
[Rails] A simple way to implement a self-introduction function in your profile
Easy way to create a mapping class when using the API
[Rails] Don't use the select method just to narrow down the columns!
An easy way to cache method calls with Ruby's native extensions