In the existing code I am working with I have found the money transfer procedure which isn’t wrapped in transaction, is it totally unacceptable or it is OK because there are all the needed sanity checks, I.e. that amount of money to transfer is greater than zero, and ORM level validation that balance is greater or equal to zero.
The reason why I actually got so baffled in the first place with this is because it comes from a solid developer, and it’s such a by-book piece of code, that seeing something like this with no transaction in sight is weird:
self.balance -= amount
save!
target.balance += amount
target.save!
Absent seeing any code, I’ll make the educated guess that the existing code is NOT acceptable. Even with the sanity checks, if a withdrawal from that account is made in between statements in the “transfer” procedure, you would have a race condition in your code which would cause a transfer of non-existent funds. The probability of this occurrence is greater when there are many concurrent users, of course.