So I've got `class Client` that `has_many :transactions`. Both fields has monetized fields (`money-rails`) gem. IN`class Transaction` I've got `after_create :add_customer_balance`. It should add this `transaction.amount` to `transaction.client` balance.

Problem I'm facing is situation when 2 transaction would be made in same moment. Let's have a look on this situation:

```
    Variant 1:
    time / process / code 
    0:01 / P1    / client = Client.find(1)
    0:01 / P2    / client = Client.find(1)
    0:02 / P1    / client.balance += 100
    0:02 / P1    / client.save # SQL: update clients set balance = 200 where id = 1
    0:03 / P2    / client.balance += 200
    0:03 / P2    / client.save # SQL: update clients set balance = 300 where id = 1

    Variant 2
    to,e / process / code 
    0:01 / P1    / client = Client.find(1)
    0:01 / P2    / client = Client.find(1)
    0:02 / P1    / client.update_all(...) # SQL: update clients set balance = balance + 100 where id = 1
    0:03 / P2    / client.update_all(...) # SQL: update clients set balance = balance + 200 where id = 1

    Result:
    Client.find(1).balance = 400

```

My question is: how to prevent first situation?

I'm looking for solution that would increase field with balance and immediately save it to database.

Edit
----

I tried doing `increment!` but it seems to doesn't prevent race condition.

```
def increment!(attribute, by = 1)
  increment(attribute, by).update_attribute(attribute, self[attribute])
end

```