Created
August 14, 2012 23:45
-
-
Save phil-monroe/3353933 to your computer and use it in GitHub Desktop.
Collect all Model Classes
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
def models | |
Module.constants.inject([]) do |models, k| | |
klass = Kernel.const_get k | |
models << klass if klass.respond_to? :ancestors and klass.ancestors.include? ActiveRecord::Base | |
models | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment