title: Run rails code after an update to the database has commited, without after_commit
body: <p>I'm trying to battle some race cases with my background task manager. Essentially, I have a <code>Thing</code> object (already exists) and assign it some properties, and then save it. After it is saved with the new properties, I queue it in Resque, passing in the ID.</p>
  
  <pre><code>thing = Thing.find(1)
  puts thing.foo # outputs "old value"
  thing.foo = "new value"
  thing.save
  ThingProcessor.queue_job(thing.id)
  </code></pre>
  
  <p>The background job will load the object from the database using <code>Thing.find(thing_id)</code>.</p>
  
  <p>The problem is that we've found Resque is so fast at picking up the job and loading the <code>Thing</code> object from the ID, that it loads a stale object. So within the job, calling <code>thing.foo</code> will still return "old value" like 1/100 times (not real data, but it does not happen often).</p>
  
  <p>We know this is a race case, because rails will return from <code>thing.save</code> <em>before the data has actually been commit to the database</em> (postgresql in this case).</p>
  
  <p>Is there a way in Rails to only execute code AFTER a database action has commit? Essentially I want to make sure that by the time Resque loads the object, it is getting the freshest object. I know this can be achieved using an <code>after_commit</code> hook on the <code>Thing</code> model, but I don't want it there. I only need this to happen in this one specific context, not every time the model has commit changed to the DB.</p>