title: Mysql2::Error: Duplicate entry for key -- ActiveRecord::RecordNotUnique not catching error?
body: <p>I am working on a rails app and have been getting the following error very often:</p>
  
  <pre><code>Mysql2::Error: Duplicate entry '3022093-2000000028003-visited' for key 'unique_user_place_relationship'
  </code></pre>
  
  <p>While I've narrowed the source of the problem down to the following lines:</p>
  
  <pre><code>begin
    up = UserPlace.new(user_place_params)
    up.skip_logging
    up.save!
  rescue ActiveRecord::RecordNotUnique =&gt; e
    Rails.logger.warn(e)
  end
  </code></pre>
  
  <p>In my table, I have the following indices:</p>
  
  <pre><code>key_name                         seq_in_index    column_name
  unique_user_place_relationship   1               user_id
  unique_user_place_relationship   2               place_id
  unique_user_place_relationship   3               relationship
  </code></pre>
  
  <p><strong>Is the problem that I don't have a <code>validate_uniqueness_of</code> user_id, place_id and relationship in my <code>user_place.rb</code>?</strong></p>
  
  <p>From my understanding, <code>ActiveRecord:RecordNotUnique</code> should catch this error since the transaction does not meet the index constraints at the db level.</p>