Flowdock
method

merge_preloads

Importance_0
v4.2.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 87
      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.