From 0f3cefa445c6b43711b29f38257adcedede74baa Mon Sep 17 00:00:00 2001 From: Byron Bischoff Date: Wed, 22 Oct 2014 11:39:47 -0700 Subject: =?UTF-8?q?copy=20reflection=5Fscopes=E2=80=99s=20unscoped=20value?= =?UTF-8?q?=20when=20building=20scope=20for=20preloading,=20fixes=20#11036?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- activerecord/lib/active_record/associations/preloader/association.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'activerecord/lib/active_record') diff --git a/activerecord/lib/active_record/associations/preloader/association.rb b/activerecord/lib/active_record/associations/preloader/association.rb index c0639742be..2300435f91 100644 --- a/activerecord/lib/active_record/associations/preloader/association.rb +++ b/activerecord/lib/active_record/associations/preloader/association.rb @@ -136,6 +136,10 @@ module ActiveRecord preload_values = preload_scope.values preload_binds = preload_scope.bind_values + if values[:unscope] + scope.unscope! values[:unscope] + end + scope.where_values = Array(values[:where]) + Array(preload_values[:where]) scope.references_values = Array(values[:references]) + Array(preload_values[:references]) scope.bind_values = (reflection_binds + preload_binds) -- cgit v1.2.3