freelancing-god/after_commit — Issue #8: after_commit_on_update with multiple updates to the same object per transaction
Author: ctaintor
Created: 2011-12-08 21:05:22+00:00
State: open

This issue is really biting us in the butt. I'm happy to commit a change to fix this, but I wanted to get some perspective before I do.

Here's the issue we're having:

we have a after_commit_on_update callback for a model. I've changed the callback to just print when it is called. Inside our code, we do something similar to this (of course these updates aren't right next to each other).

```ruby
User.transaction do
user.update_attribute(:first_name, "asdf")
user.update_attribute(:last_name, "fdsa")
end
```
Will result in
```
CALLING COMMIT UPDATE
CALLING COMMIT UPDATE
```

Now, I admit that we _probably_ shouldn't be doing these things, but we are, and it's hard to go through a relatively large codebase to fix these double-updated.

I think it makes sense to make the :committed_records_on_update collection only have one instance of an object in the collection, no matter how many times the object was updated inside the transaction. Thoughts?