lib/model_discovery/discovery.rb in model_discovery-0.2.4 vs lib/model_discovery/discovery.rb in model_discovery-0.3.0

- old
+ new

@@ -1,6 +1,8 @@ module ModelDiscovery + + # Create a list of current rails application tables or documents def self.build_table_list # Get all gem by requiring them all_gems = Bundler.require() # Discover all model files in gem files and load them @@ -13,12 +15,21 @@ end # Discover models in current rails app and load them discover Rails.root - # Create a content type entry for all Models - ActiveRecord::Base.subclasses.each do |model| - ApplicationModels.find_or_create_by(model: model.to_s) + if defined? ActiveRecord + # Create a content type entry for all Models + ActiveRecord::Base.subclasses.each do |model| + ApplicationModels.find_or_create_by(model: model.to_s) + end + end + + if defined? Mongoid + Mongoid.models.each do |model| + puts ">>>>>>>>>>>>>>>>>> ", model + ApplicationModels.find_or_create_by(model: model.to_s) + end end end private