app/models/effective/csv_importer.rb in effective_developer-0.2.10 vs app/models/effective/csv_importer.rb in effective_developer-0.2.11

- old
+ new

@@ -146,10 +146,22 @@ CSV.foreach(csv_file, headers: @has_header_row) do |row| @current_row = row begin - yield + exception = false + + ActiveRecord::Base.transaction do + begin + yield + rescue => e + exception = e + raise ActiveRecord::Rollback + end + end + + raise exception if exception + print colorize('.', :green) rescue => e error(e.message) puts row puts e.backtrace.first(3)