title: How do I check to see if my array includes an object?
body: <p>I have an array <code>@horses = []</code> that I fill with some random horses.</p>
  
  <p>How can I check if my <code>@horses</code> array includes a horse that is already included (exists) in it?</p>
  
  <p>I tried something like:</p>
  
  <pre><code>@suggested_horses = []
    @suggested_horses &lt;&lt; Horse.find(:first,:offset=&gt;rand(Horse.count))
    while @suggested_horses.length &lt; 8
      horse = Horse.find(:first,:offset=&gt;rand(Horse.count))
      unless @suggested_horses.exists?(horse.id)
         @suggested_horses&lt;&lt; horse
      end
    end
  </code></pre>
  
  <p>I also tried with <code>include?</code> but I saw it was for strings only. With <code>exists?</code> I get the following error:</p>
  
  <pre><code>undefined method `exists?' for #&lt;Array:0xc11c0b8&gt;
  </code></pre>
  
  <p>So the question is how can I check if my array already has a "horse" included so that I don't fill it with the same horse?</p>