title: Rails UI date navigation control generation (ActiveRecord logic)
body: <p>I have an app where users can view sporting events for today's date or a given date (if the user manually enters it in the URL).  A user can navigate sporting events by date with a UI control, which crudely looks like this:</p>
  
  <pre><code>Tue Nov. 27  | Wed Nov. 28  | Thu Nov. 29
  </code></pre>
  
  <p>(The dates are links except the current active one in the middle.)</p>
  
  <p>This date nav control works great for sporting events that occur nearly every day.  The user is never staring at a blank page of events.  However, for sporting events such as the NFL, events only occur on Monday, Thursday, Sunday (sometimes Saturday) and it becomes cumbersome for the user to use the date nav UI control.</p>
  
  <p>What I'd like to do is to change the logic behind the creation of the date nav UI links to include only those dates that have events.  The logic would be something like:</p>
  
  <ul>
  <li>Given today's date or a date supplied by the user, return the nearest date which has events (current_date)</li>
  <li>Given a current_date, find the nearest previous date which has events (previous_date)</li>
  <li>Given a current_date, find the nearest next date which has events (next_date)</li>
  </ul>
  
  <p>So, in the case of the NFL, the date nav UI control might look like, assuming today's date is Nov 27:</p>
  
  <pre><code>Mon Nov. 25  | Thu Nov. 29  | Sun Dec. 2
  </code></pre>
  
  <p>The way in which to tell if there are any events for a given date is by <code>start_time</code> field in the DB.</p>
  
  <p>I don't like to post a question without some code, but I'm looking for some guidance as to how I should approach this without having to hit the DB a ton of times.</p>
  
  <p>NOTE #1: When you click on a date for a sport, it returns all the events for that date. The date nav is not used for viewing individual events.</p>