From 18012bbbcaf567f7a5a19fc7241275e34c24b04c Mon Sep 17 00:00:00 2001 From: Ben Woosley Date: Tue, 16 Nov 2010 23:54:37 -0800 Subject: [PATCH] More simplicity, once again with #map --- lib/activerecord-import/import.rb | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/activerecord-import/import.rb b/lib/activerecord-import/import.rb index 460ea5d..0417073 100644 --- a/lib/activerecord-import/import.rb +++ b/lib/activerecord-import/import.rb @@ -165,15 +165,12 @@ class ActiveRecord::Base column_names = self.column_names.dup end - array_of_attributes = [] - models.each do |model| + array_of_attributes = models.map do |model| # this next line breaks sqlite.so with a segmentation fault # if model.new_record? || options[:on_duplicate_key_update] - attributes = [] - column_names.each do |name| - attributes << model.send( "#{name}_before_type_cast" ) + column_names.map do |name| + model.send( "#{name}_before_type_cast" ) end - array_of_attributes << attributes # end end # supports 2-element array and array