Forked from Kalaivanimurugan/display_model_names.rb
Created
February 23, 2022 19:48
-
-
Save synsa/472c67ccfa583af63bf5e8bca03f4220 to your computer and use it in GitHub Desktop.
List all model names in rails console
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Rails.application.eager_load! | |
ActiveRecord::Base.descendants # It returns all models and its attributes. | |
ApplicationRecord.descendants.collect(&:name) # It returns only the model names |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment