Notes posted by yeah
RSS feed
1 thank
Only works within a transaction
Of course, this has to be done in a transaction, like so:
# we've loaded user earlier and did some checks which took some time # to make sure, updates made meanwhile by other threads don't lead to # optimistic locking errors here, we do this when finally suspending User.transaction do user.lock! user.suspended = 1 user.save! end