Last active
December 21, 2023 00:29
-
-
Save alex700/906bd3bf850e130ea69d8cc78d3d3f00 to your computer and use it in GitHub Desktop.
List Ruby on Rails models
This file contains 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
# Open rails console `rails c` and run the command: | |
ActiveRecord::Base.descendants.map(&:name).each { |name| puts name } | |
# Alternatively, list classes that extend ActiveRecord::Base or any other class the application might use as a base model | |
ObjectSpace.each_object(Class).select { |klass| klass < ActiveRecord::Base }.map(&:name).sort | |
# For docker-based apps | |
docker exec -it [your_container_name] rails runner "ActiveRecord::Base.descendants.each { |model| puts model.name }" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment