Skip to content

Commit

Permalink
Merge pull request #798 from OtaYohihiro/fix_track_validation_failures
Browse files Browse the repository at this point in the history
add index when models exists
  • Loading branch information
jkowens committed Apr 14, 2023
2 parents 748309d + 2b6b867 commit 75b751f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/activerecord-import/import.rb
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,11 @@ def import_helper( *args )
return_obj = if is_validating
import_with_validations( column_names, array_of_attributes, options ) do |failed_instances|
if models
models.each { |m| failed_instances << m if m.errors.any? }
models.each_with_index do |m, i|
next unless m.errors.any?

failed_instances << (options[:track_validation_failures] ? [i, m] : m)
end
else
# create instances for each of our column/value sets
arr = validations_array_for_column_names_and_attributes( column_names, array_of_attributes )
Expand Down

0 comments on commit 75b751f

Please sign in to comment.