title: Rails query] difference between joins and includes
body: <p><code>@teachers = User.joins(:students).where("student_id IS NOT NULL")</code></p>
  
  <p>The above works, the below doesn't.</p>
  
  <p><code>@teachers = User.includes(:students).where("student_id IS NOT NULL")</code></p>
  
  <p>As far as I understand, joins and includes should both bring the same result with different performance. According to <a href="http://guides.rubyonrails.org/active_record_querying.html" rel="nofollow">this</a>, you use <code>includes</code> to load associated records of the objects called by Model, where <code>joins</code> to simply add two tables together. Using <code>includes</code> can also prevent the <code>N+1 queries</code>.</p>
  
  <p>First question: why does my second line of code not work?</p>
  
  <p>Second question: should anyone always use <code>includes</code> in a case similar to above?</p>