From d5c181f03a9fab29da3aa05e2b832479f6e08048 Mon Sep 17 00:00:00 2001 From: Neeraj Singh Date: Thu, 22 Jul 2010 15:20:53 -0400 Subject: [PATCH] No need to check for :uniq [#5170 state:resolved] --- .../associations/association_collection.rb | 9 +++------ 1 files changed, 3 insertions(+), 6 deletions(-) diff --git a/activerecord/lib/active_record/associations/association_collection.rb b/activerecord/lib/active_record/associations/association_collection.rb index f346a19..4ce3b34 100644 --- a/activerecord/lib/active_record/associations/association_collection.rb +++ b/activerecord/lib/active_record/associations/association_collection.rb @@ -478,13 +478,10 @@ module ActiveRecord callback(:before_add, record) yield(record) if block_given? @target ||= [] unless loaded? - index = @target.index(record) - unless @reflection.options[:uniq] && index - if index - @target[index] = record - else + if index = @target.index(record) + @target[index] = record + else @target << record - end end callback(:after_add, record) set_inverse_instance(record, @owner) -- 1.6.5.2