lib/model_discovery/discovery.rb in model_discovery-0.3.2 vs lib/model_discovery/discovery.rb in model_discovery-0.3.3
- old
+ new
@@ -1,9 +1,9 @@
module ModelDiscovery
# Create a list of current rails application tables or documents
- def self.build_table_list
+ def self.build_table_list(without_habtm = true)
# Get all gem by requiring them
all_gems = Bundler.require()
# Discover all model files in gem files and load them
all_gems.each do |gem|
@@ -18,16 +18,21 @@
discover Rails.root
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)
+ #unless model.name.to_s.starts_with? 'HABTM_'
+ if !model.name.to_s.starts_with?('HABTM_') && !without_habtm
+ ApplicationModels.find_or_create_by(model: model.name)
+ end
end
end
if defined? Mongoid
Mongoid.models.each do |model|
- ApplicationModels.find_or_create_by(model: model.to_s)
+ if !model.name.to_s.starts_with?('HABTM_') && !without_habtm
+ ApplicationModels.find_or_create_by(model: model.name)
+ end
end
end
end
private