5
6
7
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/preload/array_mixin.rb', line 5
def pre_load(*associations)
return if empty?
if ActiveRecord::VERSION::MAJOR >= 4
ActiveRecord::Associations::Preloader.new.preload(self, associations)
elsif defined?(ActiveRecord::Associations::Preloader)
ActiveRecord::Associations::Preloader.new(self, associations).run
elsif ActiveRecord::Base.respond_to?(:preload_associations, true)
first.class.send(:preload_associations, self, associations)
else
raise "Unsupported version of ActiveRecord"
end
end
|