Skip to content

Instantly share code, notes, and snippets.

@phil-monroe
Created August 14, 2012 23:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phil-monroe/3353933 to your computer and use it in GitHub Desktop.
Save phil-monroe/3353933 to your computer and use it in GitHub Desktop.
Collect all Model Classes
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