Displaying 1 result from an estimated 1 matches for "find_by_kind".
Did you mean:
find_by_id
2009 May 28
3
strange behaviour in ActiveRecord transaction
...nges made during the transaction is reverted
as the transaction finishes, whilst the other changes are preserved.
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.number==30
self.number=other_number
other.number=self_number
self.save
other.save
version.number+=1
version.save
#self.number==2
#other.number==1
#version.number==31
end
#self.number==1 ***Reverted!
#other.number==1
#version...