title: How to create a record only if it doesn't exist, avoid duplications and don't raise any error?
body: <p>It's well known that <code>Model.find_or_create_by(X)</code> actually does:</p>
  
  <ol>
  <li>select by X</li>
  <li>if nothing found -> create by X</li>
  <li>return a record (found or created)</li>
  </ol>
  
  <p>and there may be race condition between steps 1 and 2. To avoid a duplication of X in the database one should use an unique index on the set of fields of X. But if you apply an unique index then one of competing transactions would fail with exception (when trying to create a copy of X). </p>
  
  <p>How can I implement 'a safe version' of <code>#find_or_create_by</code> which would never raise any exception and always work as expected?</p>