<%= @inbox ? 'Message Inbox' : 'Sent Messages' %>

    <% if @inbox %>
  • › <%= link_to 'View Sent Messages', inbox_path(:sent=>true) %>
  • <% else %>
  • › <%= link_to 'Switch to Inbox', inbox_path %>
  • <% end %> <% if current_user.admin? %>
  • <%= link_to 'Contact All Users', new_message_path(:to_all=>true) %>
  • <% end %>
<% unless current_user.trainers.empty? %>
Contact your trainers:
    <% current_user.trainers.each do |tr| %>
  • <%= link_to tr.name, new_message_path(:recipient_id=>tr.id) %>
  • <% end %>
<% end %> <% @messages.each do |m| %> <% other_person = @inbox ? m.sender : m.recipient %> <% end %>
Subject <%= @inbox ? 'From' : 'To' %> <%= @inbox ? 'Received' : 'Sent' %>
<%= link_to 'View:', m %> <%= m.subject %><%= link_to other_person.name, new_message_path(:recipient_id=>other_person.id) %> <%= m.created_at.to_s(:short) %> <% if @inbox %> <%= link_to 'Reply', new_message_path(:re=>m.id) %> <% end %>

<%= will_paginate @messages %>