Skip to content

Instantly share code, notes, and snippets.

@ekumachidi
Created February 17, 2020 17:23
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ekumachidi/95ef9192b99a97f8be32a94eca7efa84 to your computer and use it in GitHub Desktop.
Save ekumachidi/95ef9192b99a97f8be32a94eca7efa84 to your computer and use it in GitHub Desktop.
List all classes in your rails app
Rails.application.eager_load!
ActiveRecord::Base.descendants # It returns all models and its attributes.
ActiveRecord::Base.descendants.collect(&:name) # It returns only the model names
# If you're using > rails 5.0 you can use the line below
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