diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2017-11-07 08:44:44 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2017-11-07 08:58:19 +0900 |
commit | 3f1695bb9c008b7cb1840e09e640f3ec0c59a564 (patch) | |
tree | 10855663d1a1035da978e623637d318557e3c320 /activerecord/lib/active_record/associations/preloader/through_association.rb | |
parent | 9042ced124874a200b134ec3a4441ab6e2c1be73 (diff) | |
download | rails-3f1695bb9c008b7cb1840e09e640f3ec0c59a564.tar.gz rails-3f1695bb9c008b7cb1840e09e640f3ec0c59a564.tar.bz2 rails-3f1695bb9c008b7cb1840e09e640f3ec0c59a564.zip |
Remove useless `associated_records_by_owner`
`associated_records_by_owner` had returned customizing result before
calling `associate_records_to_owner` for through association subclasses.
Since #22115, `associate_records_to_owner` is called in the method and
not returned owner and result pairs. Removing the method will reduce
method call and block call nesting.
Diffstat (limited to 'activerecord/lib/active_record/associations/preloader/through_association.rb')
-rw-r--r-- | activerecord/lib/active_record/associations/preloader/through_association.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/associations/preloader/through_association.rb b/activerecord/lib/active_record/associations/preloader/through_association.rb index 1bb7e98231..b1813ba66b 100644 --- a/activerecord/lib/active_record/associations/preloader/through_association.rb +++ b/activerecord/lib/active_record/associations/preloader/through_association.rb @@ -12,7 +12,7 @@ module ActiveRecord reflection.source_reflection end - def associated_records_by_owner(preloader) + def run(preloader) already_loaded = owners.first.association(through_reflection.name).loaded? through_scope = through_scope() reflection_scope = target_reflection_scope @@ -43,7 +43,7 @@ module ActiveRecord result.sort_by! { |rhs| preload_index[rhs] } if reflection_scope.order_values.any? result.uniq! if reflection_scope.distinct_value end - yield(owner, result) + associate_records_to_owner(owner, result) end end |