From c8edd4fda45bbc7c99beaaf2d53f4de59c3fac54 Mon Sep 17 00:00:00 2001 From: Yves Senn Date: Fri, 22 Mar 2013 15:02:49 +0100 Subject: do not reset associations when preloading twice. Closes #9806. As the `through_options` always contained `{:order=>nil}` the second time, the preloader ran, the association was always reset. This patch only adds the `:order` to the `through_options` if it is set. --- .../lib/active_record/associations/preloader/through_association.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'activerecord/lib/active_record') diff --git a/activerecord/lib/active_record/associations/preloader/through_association.rb b/activerecord/lib/active_record/associations/preloader/through_association.rb index 4cb7b56b57..e052b00403 100644 --- a/activerecord/lib/active_record/associations/preloader/through_association.rb +++ b/activerecord/lib/active_record/associations/preloader/through_association.rb @@ -56,8 +56,7 @@ module ActiveRecord through_options[:include] = options[:include] || options[:source] through_options[:conditions] = options[:conditions] end - - through_options[:order] = options[:order] + through_options[:order] = options[:order] if options.has_key?(:order) end through_options -- cgit v1.2.3