title: Rails named_scopes with joins
body: <p>I'm trying to create a named_scope that uses a join, but although the generated SQL looks right, the result are garbage. For example:</p>
  
  <pre><code>class Clip &lt; ActiveRecord::Base      
    named_scope :visible, {
      :joins =&gt; "INNER JOIN series ON series.id = clips.owner_id INNER JOIN shows on shows.id = series.show_id", 
      :conditions=&gt;"shows.visible = 1 AND clips.owner_type = 'Series' "
    }
  </code></pre>
  
  <p>(A Clip is owned by a Series, a Series belongs to a Show, a Show can be visible or invisible).</p>
  
  <p>Clip.all does:</p>
  
  <pre><code>SELECT * FROM `clips` 
  </code></pre>
  
  <p>Clip.visible.all does:</p>
  
  <pre><code>SELECT * FROM `clips` INNER JOIN series ON series.id = clips.owner_id INNER JOIN shows on shows.id = series.show_id WHERE (shows.visible = 1 AND clips.owner_type = 'Series' ) 
  </code></pre>
  
  <p>This looks okay. But the resulting array of Clip models includes a Clip with an ID that's not in the database - it's picked up a show ID instead. Where am I going wrong?</p>