From 6f281cf3057acb0333d6e7fe462158ea3b6fbcd7 Mon Sep 17 00:00:00 2001 From: Jon Bardin Date: Mon, 28 Sep 2020 20:25:27 -0400 Subject: [PATCH] to prevent mass-assignment errors in strict mode --- lib/activerecord-import/import.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/activerecord-import/import.rb b/lib/activerecord-import/import.rb index aa75d9aa..b7875f95 100644 --- a/lib/activerecord-import/import.rb +++ b/lib/activerecord-import/import.rb @@ -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