Hi,
I''m using an ActiveRecord transaction in a Rails app,
with Rails 2.3.2, Windows (Vista), MySQL 5.0.
No exception is being raised in the transaction, but one of the
changes made during the transaction is reverted
as the transaction finishes, whilst the other changes are preserved.
(Using "puts ..." shows the values displayed in comments in the code
below.) The same reversion is consistently happening.
The code is like:
------------------------
def swap(other)
self_number=self.number #==1
other_number=other.number #==2
ActiveRecordModel.transaction do
version=Version.find_by_kind(self.kind)
#version.ver_num==30
self.number=other_number
other.number=self_number
self.save
other.save
version.ver_num+=1
version.save
#self.number==2
#other.number==1
#version.ver_num==31
end
#self.number==1 ***Reverted!
#other.number==1
#version.ver_num==31
end
------------------------
Also, I''ve tried reversing the order of work on self and other
in the transaction, but it''s still just self.number that reverts. Any
ideas?