title: Race conditions in Rails first_or_create
body: <p>I'm trying to enforce uniqueness of values in one of my table fields. Changing the table isn't an option. I need to use ActiveRecord to conditionally insert a row into the table but I'm concerned about synchronization.</p>
  
  <p>Does <code>first_or_create</code> in Rails ActiveRecord prevent race conditions?</p>
  
  <p>This is the source code for <code>first_or_create</code> from GitHub:</p>
  
  <pre><code>def first_or_create(attributes = nil, options = {}, &amp;block)
    first || create(attributes, options, &amp;block)
  end
  </code></pre>
  
  <p>Is it possible that a duplicate entry will result in the database due to synchronization issues with multiple processes?</p>