A minor, perhaps simple, question here. Let's say my DB returns duplicates. For example, I have multiple rooms that contain different start and end times.

My current view looks like:

<table>
  <thead>
    <tr>
      <th>Location</th>
      <th>Status</th>
      <th colspan="1"></th>
    </tr>
  </thead>
  <tbody>

    <% @courses.each do |course| %>
      <% if course.lec_exam.eql?("LEC")%>
      <tr>
        <td><%= course.location %></td>
        <td><%= course.status %></td>
        <td><%= link_to 'Edit Status', edit_course_path(course) %></td>
      </tr>
      <% end %>
    <% end %>
  </tbody>
</table>

I'd like to clean this up a bit and remove the duplicates. Since each course has a location and start and end times, the same location will get displayed multiple times. What is the best approach to prevent this and display the unique locations, and then ensure that the status is correctly marked (i.e. closed means the current time is between the start and end time for each course that uses that location)? I have a few ideas but I'm not certain where to start. I can provide more information as needed.

Thanks!

Related posts

Recent Viewed