1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

No need to check for :uniq

[#5170 state:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
This commit is contained in:
Neeraj Singh 2010-07-22 15:20:53 -04:00 committed by José Valim
parent da845275dd
commit a44652baed

View file

@ -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)