diff options
author | Jon Leighton <j@jonathanleighton.com> | 2010-12-16 00:40:03 +0000 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-12-15 17:47:42 -0800 |
commit | 09ddca67acbb88e2fdd7300670839cbf647b2694 (patch) | |
tree | c0be01dd066c966daaf76e35be91e41567f6cb96 /activerecord/lib/active_record | |
parent | 6bfa846a2cc950bbb3d8b30f076589a60f38b821 (diff) | |
download | rails-09ddca67acbb88e2fdd7300670839cbf647b2694.tar.gz rails-09ddca67acbb88e2fdd7300670839cbf647b2694.tar.bz2 rails-09ddca67acbb88e2fdd7300670839cbf647b2694.zip |
Fix problem with duplicated records when a :uniq :through association is preloaded [#2447 state:resolved]
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/association_preload.rb | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/association_preload.rb b/activerecord/lib/active_record/association_preload.rb index 5eb1071ba2..f2094283a2 100644 --- a/activerecord/lib/active_record/association_preload.rb +++ b/activerecord/lib/active_record/association_preload.rb @@ -251,6 +251,7 @@ module ActiveRecord through_record_id = through_record[reflection.through_reflection_primary_key].to_s add_preloaded_records_to_collection(id_to_record_map[through_record_id], reflection.name, through_record.send(source)) end + records.each { |record| record.send(reflection.name).target.uniq! } if options[:uniq] end else |