Module: PolymorphicConstraints::Utils::PolymorphicModelFinder

Included in:
ConnectionAdapters::Mysql2Adapter, ConnectionAdapters::PostgreSQLAdapter, ConnectionAdapters::SQLite3Adapter
Defined in:
lib/polymorphic_constraints/utils/polymorphic_model_finder.rb

Instance Method Summary collapse

Instance Method Details

#get_polymorphic_models(relation) ⇒ Object



4
5
6
7
8
9
# File 'lib/polymorphic_constraints/utils/polymorphic_model_finder.rb', line 4

def get_polymorphic_models(relation)
  Rails.application.eager_load!
  ActiveRecord::Base.descendants.select do |klass|
    contains_polymorphic_relation?(klass, relation)
  end
end