1 <h1>Listing groups</h1> 2 3 <table> 4 <tr> 5 <th>Name</th> 6 </tr> 78 <% @groups.each do |group| %> 9 <tr> 10 <td><%=h group.name %></td> 11 <td><%= link_to 'Show', group %></td> 12 <td><%= link_to 'Edit', edit_group_path(group) %></td> 13 <td><%= link_to 'Destroy', group, :confirm => 'Are you sure?', :method => :delete %></td> 14 </tr> 15 <% end %> 16 </table>17 18 <br /> 19 20 <%= link_to 'New group', new_group_path %>
This code is the standard scaffolding index page. The highlighted portion from lines 8 to 16 is the loop that displays each existing group. But since we don’t have any groups in our database right now, let’s substitute an empty array for the “@groups” variable.
Next, click “Substitute value for @groups.”