Issue updating database from csv file


I have an action that uploads a csv file of users to the website.
(Uploads fine)

The code loops through each row checking if the user already exists and
then either updating the attributes or adding a new user to the

The csv file has over 3000 rows and does not complete.
(At one point I got an error:
A ActiveRecord::Transactions::TransactionError occurred in

Transaction aborted

I have tried with smaller csv files, 1000 lines, and some times it works
and others it fails.

The code uses the and each to loop through the rows.

Has anyone had an issue like this or know what is happening?