title: Join statement in ruby on rails throws up error MySQL::Error: Unknown column
body: <pre><code>parts = Participation.joins(:booking).where(bookings: { date_of_booking: Date.yesterday }, payment_status: 2)
  </code></pre>
  
  <p>I have the above join statement, even though the column <code>date_of_booking</code> exists, mysql throws up error </p>
  
  <blockquote>
    <p>ActiveRecord::StatementInvalid: Mysql2::Error: Unknown column 'bookings.date_of_booking' in 'where clause': SELECT <code>ad_trek_participant</code>.* FROM <code>ad_trek_participant</code> INNER JOIN <code>ad_trek_booking</code> ON <code>ad_trek_booking</code>.<code>Id</code> = <code>ad_trek_participant</code>.<code>Booking_Id</code> WHERE <code>bookings</code>.<code>date_of_booking</code> = '2017-02-13' AND <code>ad_trek_participant</code>.<code>payment_status</code> = 2</p>
  </blockquote>
  
  <p>Any help on this please.</p>