title: How to take a list of objects and join them on a query in ActiveRecord
body: <p>Due to policies and users being on two different databases, I cannot add where clauses to my "includes" statements (throws table doesn't exist error due to the way AR constructs a single query instead of using different queries).  I can do <code>Policies :belongs_to Users</code> and then when I do <code>Policies.active.state('NY).includes(:users)</code> I also get the user associated with that poicy, but i cannot do <code>Policies.active.state('NY').includes(:users).where(users: {status_code: 'A'})</code> because it throws the table does not exist error on users (in the other database).</p>
  
  <p>So what I want to do is be able to take the results from:</p>
  
  <pre><code>policies = Policies.active.state('NY').includes(:users)
  </code></pre>
  
  <p>and throw out the policies that do not contain users returned from:</p>
  
  <pre><code>Users.where(status_code: 'A')
  </code></pre>
  
  <p>and if the query could only be execuited against the users that return from the first query,that would be best</p>