Rails activerecord joins and duplicates data
<p>I'm having a <code>route</code> model </p>

<pre><code>class Route &lt; ActiveRecord::Base
  has_many :etapes
  acts_as_mappable :through =&gt; :steps
end
</code></pre>

<p>and a <code>step</code> one (that contains lat and lgn)</p>

<pre><code>class Step ActiveRecord::Base
  belongs_to :route
  acts_as_mappable
end
</code></pre>

<p>I'm trying to get the closest <code>route</code> to a given point.</p>

<p>With this request <code>Route.joins(:etapes).within(10, :origin =&gt; [1.23456,-5.3269])</code> I can get the <code>route</code>s but I got duplicates informations (because this <code>route</code> has many steps closes to the given point):</p>

<pre><code>#&lt;ActiveRecord::Relation [
#&lt;Route id: 1, created_at: "2016-03-26 21:53:01", updated_at: "2016-03-26 21:53:01"&gt;, 
#&lt;Route id: 1, created_at: "2016-03-26 21:53:01", updated_at: "2016-03-26 21:53:01"&gt;
]&gt;
</code></pre>

<p>What can I do to remove duplicates entries ?</p>