 <p>I have found solution of my question's</p> <pre><code>@hotels = [] hotels.map{|hotel| @hotels &lt;&lt; hotel unless @hotels.map(&amp;:id).include? hotel.id} </code></pre> <p>and now <code>@hotels.map(&amp;:id)</code> return <code>[42, 47, 48, 41, 43, 39, 40, 44, 46, 45]</code></p>