Ruby on Rails: Loops and other Tricks in Views
<!--# Flash notice-->
<% flash.each do |key, value| %>
<%= content_tag :li, value, class: "flash #{key}" %>
<% end %>
<!--# Flash errors-->
<% flash.each do |key, value| %>
<%= content_tag :li, value.join(". "), class: "flash #{key}" %>
<% end %>
<!--# Table listing database entries-->
<tbody>
<% @class.each do |student| %>
<tr>
<td><%= student.first_name %></td>
<td><%= student.last_name %></td>
<td><%= student.email %></td>
</tr>
<% end %>
</tbody>
<!--# Form list with selected value-->
<% @dojos.each do |dojo| %>
<% if dojo == @current_dojo %>
<option selected value="<%= dojo.id %>"><%= dojo.branch %></option>
<% else %>
<option value="<%= dojo.id %>"><%= dojo.branch %></option>
<% end %>
<% end %>
<!--# Form input with existing value-->
<input type="text" name="student[name]" value="<%= @student.name %>" />
<!--# Navigation using routes-->
<%= link_to "Home", root_path %> |
<%= link_to "#{@student.name}", dojo_student_path(@student.dojo_id, @student) %>
<!--# Conditional on relationship count-->
<% if user.tweets.count > 1 %>
<% end %>