title: Friendly_id Unique contraint with scope and history
body: <pre><code>'rails', '~&gt; 5.1.2'
  'friendly_id', '~&gt; 5.1.0'
  </code></pre>
  
  <p>I'm trying to add 'scoped' to my existing slugs.</p>
  
  <pre><code>class Model &lt; ApplicationRecord   
    extend FriendlyId   
    belongs_to :board   
    friendly_id :slug_candidates, use: [:slugged, :scoped, :history], :scope =&gt; :board
  </code></pre>
  
  <p>But I'm coming up with this error when a duplicate is run that should have a different scope.</p>
  
  <blockquote>
    <p>ActiveRecord::RecordNotUnique: PG::UniqueViolation: ERROR:  duplicate
    key value violates unique constraint "index_models_on_slug" DETAIL: 
    Key (slug)=(xxx-xxxx-xxx) already exists.</p>
  </blockquote>
  
  <p>Looking through the logs, I can see the scope is generating and lists the scope model (via board_id, xx), which I assume is as it should, but it doesn't seem to be searching the scope when saving.</p>
  
  <p>If I create a duplicate under that same scope, it adds the duplicate code ("42a8d035-ba2f-4a51-b85e-0872c4e207e2").</p>
  
  <p>I hope this makes sense - Any help would be appreciated.</p>
  
  <p>Thanks,
  Andy</p>