From 4a785415559cdb8aae00d636bd364994fec36311 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Tue, 24 Sep 2013 11:37:17 -0700 Subject: [PATCH] all records have a preloaded, so eliminate that conditional --- .../preloader/through_association.rb | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/activerecord/lib/active_record/associations/preloader/through_association.rb b/activerecord/lib/active_record/associations/preloader/through_association.rb index 15fdba51f3..7187cf38fd 100644 --- a/activerecord/lib/active_record/associations/preloader/through_association.rb +++ b/activerecord/lib/active_record/associations/preloader/through_association.rb @@ -52,17 +52,13 @@ def associated_records_by_owner(preloader) r.send(source_reflection.name) }.compact - if pl - loaded_records = pl.preloaded_records - i = 0 - record_index = loaded_records.each_with_object({}) { |r,indexes| - indexes[r] = i - i += 1 - } - rhs_records.sort_by { |rhs| record_index[rhs] } - else - rhs_records - end + loaded_records = pl.preloaded_records + i = 0 + record_index = loaded_records.each_with_object({}) { |r,indexes| + indexes[r] = i + i += 1 + } + rhs_records.sort_by { |rhs| record_index[rhs] } end } end -- GitLab