Module: Preload::ArrayMixin
- Defined in:
- lib/preload/array_mixin.rb
Instance Method Summary collapse
Instance Method Details
#pre_load(*associations) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/preload/array_mixin.rb', line 5 def pre_load(*associations) return if empty? if ActiveRecord::VERSION::MAJOR >= 7 ActiveRecord::Associations::Preloader.new(records: self, associations: associations).call elsif ActiveRecord::VERSION::MAJOR >= 5 ActiveRecord::Associations::Preloader.new.preload(self, associations) else raise "Unsupported version of ActiveRecord" end end |