I am having a strange problem. I am trying to update a bunch of records like this
a.each do |a|
b = Company.find_by_id(a.company_id)
b.col_name = Time.now
b.save
end
after I run this, I check the DB and the column “col_name” is indeed
updated. However, if I check the DB 5-10 minutes later, all
changes are gone. I’ve tried update_attribute, same problem.
I am having a strange problem. I am trying to update a bunch of records
like this
a.each do |a|
b = Company.find_by_id(a.company_id)
b.col_name = Time.now
b.save
end
after I run this, I check the DB and the column "col_name" is indeed
updated. However, if I check the DB 5-10 minutes later, all changes are
gone. I've tried update_attribute, same problem.
Try checking your configuration and verify that database auto-commit is turned on.
Does anone know what else can be wrong with my DB? Every once in
a while my Updates don’t get committed. The application was
working fine all morning, but just now one update got rolled back
again. My @@autocommit is enabled, I am not using any
transactions, it’s a simple update.
I check save and it works fine. I check the DB after I run update
and the records are updated (most of the time). However, every
once in a while, if I check the table that was updated 5 minutes later,
all changes are rolled back. I realized that it’s the issue with
MySQL, not Rails. Is my MySQL missing some crucial configuration
that I am not aware of?. I am using MySQL 5, InnoDB and my
@@autocommit is enabled. I posted a question on mysql.com several
days ago but never got a single response.
Yes, I can reproduce this error within MySQL client. So, it’s
defintely not a Rails issue. I can only reproduce this error a
few times a day, usually it works fine. I am running
Version: ‘5.0.22’ on FC 5 and my @@autocommit is enabled.