Created
July 14, 2009 23:46
-
-
Save altamic/147328 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
# produce an array of active record models for a ruby on rails app | |
# by Michelangelo Altamore | |
def _models | |
Dir.new(File.join(RAILS_ROOT, 'app', 'models')).select do |f| | |
f =~ /\.rb$/ | |
end.map do |file| | |
model = file.gsub!(/\.rb$/, '').camelize | |
if model.constantize.ancestors.include?(ActiveRecord::Base) | |
model | |
else | |
nil | |
end | |
end.compact | |
end if ENV.include?('RAILS_ENV') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment