From a44652baed1d26a4f63380c406e05f7a2ddd4a12 Mon Sep 17 00:00:00 2001 From: Neeraj Singh Date: Thu, 22 Jul 2010 15:20:53 -0400 Subject: No need to check for :uniq MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [#5170 state:resolved] Signed-off-by: José Valim --- .../lib/active_record/associations/association_collection.rb | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'activerecord') diff --git a/activerecord/lib/active_record/associations/association_collection.rb b/activerecord/lib/active_record/associations/association_collection.rb index f346a19a3a..4ce3b34819 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) -- cgit v1.2.3