-
-
Save rubiety/29404 to your computer and use it in GitHub Desktop.
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
# If you ever needed an array of all ActiveRecord models in your Rails app (+ Session): | |
Dir["app/models/**/*.rb"].each {|r| require r} | |
subclasses_of(ActiveRecord::Base).map(&:class_name) | |
# Or *all* models: | |
ActiveRecord::Base.connection # Preloads driver constants | |
constants_before = Object.constants | |
Dir["app/models/**/*.rb"].each {|r| require r} | |
Object.constants - constants_before |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment