title: collection.exists? lies to me
body: <p>In my ruby model I have a has_and_belongs_to_many relation with a model "search":</p>
  
  <pre><code>has_and_belongs_to_many :searches
  </code></pre>
  
  <p>I want to add a new search object only if it does not already exists, so I wrote:</p>
  
  <pre><code>def append_unless_already_there search
    unless searches.exists?(search)
      searches &lt;&lt; search
  end
  </code></pre>
  
  <p>However, adding 2 times a new object passes the condition, and results in a sql exception. Tried replacing search with search.id, but does not change anything. 
  I added some logging to the code:</p>
  
  <pre><code>def append_unless_already_there search
    puts ""
    puts searches.exists?(search)
    unless searches.exists?(search)
      puts "["
      searches.each do |s|
        puts s.id
      end
      puts "]"
      puts search.id
  
      searches &lt;&lt; search
    end
  end
  </code></pre>
  
  <p>Adding 5 search objects, of which the last 2 are equal, results in the following logging when adding the last object:</p>
  
  <pre><code>false
  [
  12
  5
  8
  1
  ]
  1
  </code></pre>
  
  <p>As I read the documentation and examples given, this last exists? check should return true. I cannot figure out what I am missing here. Thanks in advance.</p>