Class: ValidationErrorReporter::Entity

Inherits:
Object
  • Object
show all
Defined in:
lib/validation_error_reporter/entity.rb

Class Method Summary collapse

Class Method Details

.models_for(model_names = []) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/validation_error_reporter/entity.rb', line 5

def self.models_for(model_names = [])
  if model_names.nil? || model_names.empty?
    ActiveRecord::Base.descendants
  else
    model_names.collect do |model_name|
      model_name.classify.safe_constantize
    end
  end.reject do |model|
    !model.public_methods.include?(:all) || model.abstract_class? ||
      !model.table_exists? ||  model.name.include?("HABTM_")
  end
end