method

merge_preloads

Importance_0
v6.1.7.7 - Show latest stable - 0 notes - Class: Merger
merge_preloads() private

No documentation

This method has no description. You can help the Ruby on Rails community by adding new notes.

Hide source
# File activerecord/lib/active_record/relation/merger.rb, line 89
        def merge_preloads
          return if other.preload_values.empty? && other.includes_values.empty?

          if other.klass == relation.klass
            relation.preload_values |= other.preload_values unless other.preload_values.empty?
            relation.includes_values |= other.includes_values unless other.includes_values.empty?
          else
            reflection = relation.klass.reflect_on_all_associations.find do |r|
              r.class_name == other.klass.name
            end || return

            unless other.preload_values.empty?
              relation.preload! reflection.name => other.preload_values
            end

            unless other.includes_values.empty?
              relation.includes! reflection.name => other.includes_values
            end
          end
        end
Register or log in to add new notes.