Hey there I have an app where:
  • A user has and belongs to many videos
  • A video has and belongs to many users. And belongs to a group.
  • A group has many videos

On the 'Show' action of the user, I have it print out all the videos that user is in along with the group if that video. Here is a snippet of the ERB file.
<% if @user.videos != [] -%>
<tr><th>I'm in these videos:</th></tr>
<% for video in @user.videos -%>
<tr><td><%= link_to video.name, video %> - <%= link_to video.group.name, video.group %></td></tr>
<% end -%>
<% else -%>
<tr><th>This user is currently in no videos.</tr></th>
<% end -%>
Is there a way I can order the list by the group name?

Thanks in advance!