<div class="dashboard-wrapper">
  <div class="main-container">
    <div class="row-fluid">
        <div class="span12">
          <div class="widget">
            <div class="widget-header">
              <div class="title">
                <span class="fs1" aria-hidden="true" data-icon="&#xe022;"></span> Messages for <%= current_user.full_name %>
                  <span class="fs1" aria-hidden="true" data-icon="&#xe006;"><%= link_to "Send Message", new_user_message_path %></span>
              </div>
            </div>
            <div class="widget-body">
              <table class="table table-bordered table-striped">
                <thead>
                  <tr>
                    <th style="width:7%">From:</th>
                    <th style="width:6%">Date</th>
                    <th style="width:16%">Message</th>
                    <th style="width:6%">Actions</th>
                  </tr>
                </thead>
                <tbody>
                    <tr>
                    <% if @messages.empty? %>
                    <td><%= "No messages!" %></td><td></td><td></td><td></td>
                    <% end %>
                <% @messages.each do |message| %>
                    <td><%= message.creator_name %></td>
                    <td><%= message.created_at.to_date %></td>
                    <td><%= message.message %></td>
                    <td><%= link_to "Details", user_message_path(:id => message.id), {:class => "btn btn-info pull-left"}%>
                    <%= link_to "Delete", user_message_path(:id => message.id), {:method => 'delete', :class => "btn btn-danger pull-left"}%></td>
                    </tr>
                </tbody>
                <% end %>
              </table>
            </div>
          </div>
        </div>
    </div>
  </div>
</div>      
</body>
</html>

<script>
function makeActive(){
	$('li[id="messages"]').addClass('active');
};

$(document).ready(function () {
  makeActive()
});

</script>