title: ActiveRecord. Find all records by attribute the values of which are included in array
body: <p>I need to create a scope on my <code>User</code> model that would get all the users whose email attribute is included into the <code>AdminUser</code> model's emails.</p>
  
  <p>Basically, there's an attribute called <code>email</code> in the <code>User</code> model and the same attribute in the <code>AdminUser</code> model. So, I need to get all the users which are actually admins (by emails).</p>
  
  <p>I didn't succeed in implementing this as a signle query and started with getting the array  of <code>AdminUser</code> emails:</p>
  
  <pre><code>emails = AdminUser.pluck(:email)
  </code></pre>
  
  <p>and now I'm struggling with getting the array of admin users from <code>User</code> model.</p>
  
  <p>If I write something like this: </p>
  
  <pre><code>User.find_by_email(emails)
  </code></pre>
  
  <p>I get just one entity, not the array.</p>
  
  <hr>
  
  <p>So, my question:</p>
  
  <p>How can I create a scope, say <code>admins</code>, on the <code>User</code> model that would return the array of admins?</p>
  
  <hr>
  
  <p>BTW: for some other purposes I have this method in my <code>User</code>:</p>
  
  <pre><code>  def admin?
      AdminUser.find_by(email: email) ? true : false
    end
  </code></pre>
  
  <p>so, maybe I could somehow make use of it in this case?</p>