Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Ensure models are loaded; support for STI; support for Mongoid #1

Merged
merged 1 commit into from

2 participants

@schnittchen

No description provided.

@joernchen joernchen merged commit a40f2a2 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 26, 2012
This page is out of date. Refresh to see the latest.
Showing with 8 additions and 1 deletion.
  1. +8 −1 good_stuff/attr_scanner.rb
View
9 good_stuff/attr_scanner.rb
@@ -4,8 +4,15 @@
# should be run from rails console in production
# environment.
+#make sure all models are loaded
+Dir[Rails.root + 'app/models/**/*.rb'].each { |path| require path }
-ActiveRecord::Base.subclasses.each do |m|
+models = ActiveRecord::Base.subclasses
+## for mongoid:
+# ObjectSpace.each(Class).select { |c| c < Mongoid::Document }
+## (does not work in all rubies)
+
+models.each do |m|
mod = m.new
puts "All attributes for model #{m}:"
mod.attributes.each_key do |k|
Something went wrong with that request. Please try again.