title: How to use a model scope on a .joins query
body: <p>I have 2 models - User and User_detail.</p>
  
  <p>Tables:</p>
  
  <pre><code>User
  |id|
  
  User_detail
  |id|user_id|active|
  </code></pre>
  
  <p>UserDetails model:</p>
  
  <pre><code>class UserDetails &lt; ActiveRecord::Base
      belongs_to :user
  
      scope :active, -&gt; { where("active is null or active = true") }
  end
  </code></pre>
  
  <p>How can I use this scope in a query to get only the active users?</p>
  
  <p>Something like this:</p>
  
  <pre><code> User.joins(:user_details).active
  </code></pre>