title: Prevent duplicates from saving in active record, and return the object that was duplicated
body: <p>I'm having a few issues with duplicate records in my database which I believe are being caused by people clicking submit multiple times. I am using Rails 3.</p>
  
  <p><strong>Return the duplicated object rather than false</strong></p>
  
  <p>I would like to be able to prevent duplicates from being added to my database, but would prefer it if when saving a duplicate, the object that was duplicated was returned, rather than false. The reason being that if someone clicks submit several times, I would like them to be taken to a page showing them the item they submitted first, rather than to an error page.</p>
  
  <p><strong>Definition of a duplicate</strong></p>
  
  <p>I'm defining a duplicate as an item in which all the fields except the ID are the same, and created_at > Time.now - 1.minute</p>
  
  <p><strong>No JavaScript</strong></p>
  
  <p>I would prefer to do this serverside rather than just disabling the button in JavaScript since I don't think database integrity is a client side job. Also, it feels like it should be done in the model, rather than the controller. I'm running multiple passengers, so any solution should ideally avoid concurrency issues as much as possible. A few edge case duplications would not break the site though.</p>
  
  <p>Thanks.</p>