title: Referencing an associated table in an ActiveRecord where/join call
body: <p>Lets say I have two Rails models, Users and Lists. Users have_many lists and lists belong_to a user.</p>
  
  <p>Users also have one particular list they are working on at any given time. This is denoted by the active_list_id foreign key on the User model.</p>
  
  <p>Let's say I want to run the equivalent of the following query via ActiveRecord:</p>
  
  <pre><code>SELECT * FROM users JOIN lists 
  ON lists.id = users.active_list_id
  </code></pre>
  
  <p>Basically I am trying to write a method which will get each user, along with her currently active list, to display statistics on list completion. </p>
  
  <p>The solution seems to me to be something like</p>
  
  <pre><code>Users.joins(:lists).where("users.active_list_id  = lists.id") 
  </code></pre>
  
  <p>But I can't seem to get that to work**, and I'm not sure what the most idiomatically correct solution is in Rails.</p>
  
  <p>How should I pull this data most efficiently and effectively using ActiveRecord? </p>
  
  <p>Thanks in advance for any help you can offer.</p>
  
  <p>EDIT: The above query does work, but does not seem to pull a conjunction of the user record and its associated list.</p>