Skip to content

Commit

Permalink
to prevent mass-assignment errors in strict mode
Browse files Browse the repository at this point in the history
  • Loading branch information
diclophis committed Sep 29, 2020
1 parent 3eaaef8 commit 6f281cf
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/activerecord-import/import.rb
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,8 @@ def import_helper( *args )
# keep track of the instance and the position it is currently at. if this fails
# validation we'll use the index to remove it from the array_of_attributes
arr.each_with_index do |hsh, i|
model = new(hsh)
model = new
hsh.each_pair { |k, v| model[k] = v }
next if validator.valid_model?(model)
raise(ActiveRecord::RecordInvalid, model) if options[:raise_error]
array_of_attributes[i] = nil
Expand Down

0 comments on commit 6f281cf

Please sign in to comment.