<% @alert = 0 %> <% mission.mission_agents.each do |agent|%> <% agent.mission_agent_steps.each do |step| %> <% if step.status == "Waiting Validation" %> <% @alert = @alert + 1 %> <% end%> <% end %> <% end %> <% if @alert > 0 %> <%= @alert %> <% end %>