title: Querying using a has_many relationship
body: <p>I'm not sure the title makes sense, but I have a <code>users</code> model and a <code>schedule</code> model. The <code>user</code> <code>has_many: schedules</code> and <code>schedule</code> <code>belongs_to: user</code>. </p>
  
  <p>A Schedule is a model with a day, and start and end time. Essentially a user has many schedule objects for each time they are available (i.e. if they are free on Monday from 5am-10am the object will be <code>{day: 0, start: 5, end: 10}</code> (0 is Monday, 1 Tuesday, etc.)</p>
  
  <p>I would like to query all users who (on a given day at any given hour) have a schedule object that contains that hour. </p>
  
  <p>Something along the lines of <code>Users.where(user.schedule.day: params[:day], user.schedule.start &lt; params[:start], user.schedule.end &gt; params[:end])</code>.</p>
  
  <p>Obviously this doesn't work and I can't figure out what this type of query is called to look for a good answer.</p>
  
  <p>Any help is appreciated! Thanks.</p>