diff options
author | Neeraj Singh <neerajdotname@gmail.com> | 2010-07-26 15:12:36 -0400 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-08-02 17:12:59 +0200 |
commit | 009aa8825b6932b006f005ac351b82ad8100d7f1 (patch) | |
tree | 5e5a86d710a45399347adbc38a22db1b4a2a3fad /activerecord/lib | |
parent | 59693c4c49cce5e4cf53eb54e42e3da07a98467e (diff) | |
download | rails-009aa8825b6932b006f005ac351b82ad8100d7f1.tar.gz rails-009aa8825b6932b006f005ac351b82ad8100d7f1.tar.bz2 rails-009aa8825b6932b006f005ac351b82ad8100d7f1.zip |
Eager loading an association should not change the count of children
[#4971 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/associations.rb | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb index 1dc094b893..9cd3b9662f 100644 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -1815,6 +1815,10 @@ module ActiveRecord when Hash associations.keys.each do |name| reflection = base.reflections[name] + + if records.any? && reflection.options && reflection.options[:uniq] + records.each { |record| record.send(reflection.name).target.uniq! } + end parent_records = [] records.each do |record| |