<h1>Listing messages</h1>
<div class="container">
<table class="table table-bordered table-striped table-highlight">
  <thead>
  <tr>
    <th>Name</th>
    <th>ID</th>
  </tr>
  </thead>
  <tbody>
<% @conversations.each do |conversation| %>
  <tr>
    <% unless conversation.id == current_user.id %>
      <td><a href="<%=message_path(Message.select("id").where("(senderID = ? AND recipientID = ?) OR (senderID = ? AND recipientID = ?)",conversation,current_user.id,current_user.id,conversation).map(&:id).last)%>"><%= conversation.name %></a></td>
      <td><%= conversation.id %></td>
    <% end %>
  </tr>
<% end %>
  </tbody>
</table>
</div>

<br />

<%= link_to 'New Message', new_message_path %>
