Skip to content

Instantly share code, notes, and snippets.

@synsa
Forked from Kalaivanimurugan/display_model_names.rb
Created February 23, 2022 19:48
Show Gist options
  • Save synsa/472c67ccfa583af63bf5e8bca03f4220 to your computer and use it in GitHub Desktop.
Save synsa/472c67ccfa583af63bf5e8bca03f4220 to your computer and use it in GitHub Desktop.
List all model names in rails console
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