Created
February 26, 2011 19:59
-
-
Save maxwell/845562 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
#when i do this | |
def require_all_model_classes | |
# Rails only loads classes when they are used | |
# To populate our registry we require each file in app/models | |
models = Dir.entries(Rails.root.to_s + '/app/models/').select{|f| f =~ /^\w/} | |
puts models.inspect | |
models.each do |f| | |
f.sub('.rb', '').classify.constantize | |
end if defined?(Rails) | |
end | |
end |
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
["aspect.rb", "aspect.rbc", "aspect_membership.rb", "aspect_membership.rbc", "comment.rb", "comment.rbc", "contact.rb", "contact.rbc", "data_point.rb", "data_point.rbc", "invitation.rb", "invitation.rbc", "jobs", "mention.rb", "mention.rbc", "mongo.rb", "mongo.rbc", "notification.rb", "notification.rbc", "notification_actor.rb", "notification_actor.rbc", "person.rb", "person.rbc", "photo.rb", "photo.rbc", "post.rb", "post.rbc", "post_visibility.rb", "post_visibility.rbc", "profile.rb", "profile.rbc", "request.rb", "request.rbc", "retraction.rb", "retraction.rbc", "service.rb", "service.rbc", "services", "statistic.rb", "statistic.rbc", "status_message.rb", "status_message.rbc", "user.rb", "user.rbc"] |
sarahmei
commented
Feb 26, 2011
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment