<div id="messages">
  <h1>Private Message</h1>

  <% @messages.each do |message| %>
    <div class="message">
      <h3 class="subject <%= message.recipient == @message.recipient ? "sender" : "recipient" %>">
        <%= icon("chevron-right") if message == @message %>
        <%= namelink message %>
      </h3>
      <div class="content">
        <%= raw message.text_parsed %>
      </div>
      <p>Sent by: <%= namelink message.sender %> on <%= shortdate message.created_at %></p>
      <p>
        <%= link_to "Reply", 
          { controller: "messages", action: "new", id: message.sender_type, id2: message.sender_id, title: message.title },
          { class: 'button tiny'} %>
      </p>
    </div>
  <% end %>

  <%= link_to 'Back to Messages', messages_path, class: 'button back' %>
</div>
  