method

merge_preloads

Importance_0
v5.0.0.1 - Show latest stable - 0 notes - Class: Merger

Not found

The exact documentation you were looking for could not be found. Here is the best guess.

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 86
      def merge_preloads
        return if other.preload_values.empty? && other.includes_values.empty?

        if other.klass == relation.klass
          relation.preload!(*other.preload_values) unless other.preload_values.empty?
          relation.includes!(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.