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:
parent
da845275dd
commit
a44652baed
1 changed files with 3 additions and 6 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue