method
load_target
rails latest stable - Class:
ActiveRecord::Associations::AssociationCollection
load_target()protected
No documentation available.
# File activerecord/lib/active_record/associations/association_collection.rb, line 393
def load_target
if [email protected]_record? || foreign_key_present
begin
if !loaded?
if @target.is_a?(Array) && @target.any?
@target = find_target.map do |f|
i = @target.index(f)
if i
@target.delete_at(i).tap do |t|
keys = ["id"] + t.changes.keys + (f.attribute_names - t.attribute_names)
t.attributes = f.attributes.except(*keys)
end
else
f
end
end + @target
else
@target = find_target
end
end
rescue ActiveRecord::RecordNotFound
reset
end
end
loaded if target
target
end