No need to check for :uniq
[#5170 state:resolved] Signed-off-by: José Valim <jose.valim@gmail.com>
This commit is contained in:
parent
da845275dd
commit
a44652baed
@ -478,13 +478,10 @@ def add_record_to_target_with_callbacks(record)
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user