<% group.forums.sort_by{ |f| f.position || 0 }.each do |f| %>
<% if f.can_read?(current_user) %>
<%= link_to f.name, f, id: "forum-#{f.id}"%>
<% if last_thread = f.threads.last %>
<% last_reply = Threadreply.where(forumthread: f.threads).order(:created_at).last %>
<% if last_reply && last_reply.created_at > last_thread.created_at %>
<%= last_reply.author.name %> <%= link_to "replied", forumthread_path(last_reply.thread) + "#reply-#{last_reply.id}" %> .
<% else %>
<%= last_thread.author.name %> <%= link_to "posted", forumthread_path(last_thread) %> .
<% end %>
<% else %>
No posts yet.
<% end %>