title: Rails 4 ActiveRecord - how to see how is interpreted a database query?
body: <p>I have these models:</p>
  
  <p><strong>teacher</strong></p>
  
  <pre><code>class Teacher &lt; ActiveRecord::Base
    has_many :days
  end
  </code></pre>
  
  <p><strong>day</strong></p>
  
  <pre><code>class Day &lt; ActiveRecord::Base
    belongs_to :teacher
  end
  </code></pre>
  
  <p>And running these query:</p>
  
  <pre><code>  active_teachers = Teacher.joins(:days).where("teacher.id" =&gt; found_teachers.pluck(:teacher_id).uniq, "days.day_name" =&gt; selected_day)
  </code></pre>
  
  <p>What the query (should) does: <code>found_teachers</code> is an array of all teachers with duplications, remove the duplicity and chose only those teachers that have classes on a respective day (<code>selected_day</code> contains a string, <code>Monday</code> for example).</p>
  
  <p>Because the amount of data in the variable <code>active_teachers</code> is so big that I can't manually go record  by record (and I am not sure that I built this query properly and it does exactly what I need), I am trying to find out how is this query translated to SQL from ActiveRecord.</p>
  
  <p>Usually I see everything in the terminal where is running server for the Rails app, but as of now, I don't see there this query stated.</p>
  
  <p>So the question is, how can I see how the ActiveRecord query is translated to SQL?</p>
  
  <p>Thank you in advance.</p>