aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorNeeraj Singh <neerajdotname@gmail.com>2010-07-22 15:20:53 -0400
committerJosé Valim <jose.valim@gmail.com>2010-07-26 17:41:04 +0200
commita44652baed1d26a4f63380c406e05f7a2ddd4a12 (patch)
treed01138f83706e447898d4487c57326ea59124774 /activerecord
parentda845275dde0f7c13f4a24c0366f809c5006e70a (diff)
downloadrails-a44652baed1d26a4f63380c406e05f7a2ddd4a12.tar.gz
rails-a44652baed1d26a4f63380c406e05f7a2ddd4a12.tar.bz2
rails-a44652baed1d26a4f63380c406e05f7a2ddd4a12.zip
No need to check for :uniq
[#5170 state:resolved] Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/associations/association_collection.rb9
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 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)