mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
@target should always be an array
This commit is contained in:
@@ -354,12 +354,13 @@ module ActiveRecord
|
||||
def add_to_target(record)
|
||||
callback(:before_add, record)
|
||||
yield(record) if block_given?
|
||||
@target ||= [] unless loaded?
|
||||
|
||||
if @reflection.options[:uniq] && index = @target.index(record)
|
||||
@target[index] = record
|
||||
else
|
||||
@target << record
|
||||
end
|
||||
|
||||
callback(:after_add, record)
|
||||
set_inverse_instance(record)
|
||||
record
|
||||
|
||||
Reference in New Issue
Block a user