作业#新
<ul>
<% if current_user.jobs.any? %>
<% current_user.jobs.each do |job| %>
<li> Job ID: <%= job.id %> Recipient: <%= job.recipient %> </li>
<% else %>
<%= "You have no jobs" %>
<% end %>
<% end %>
不确定我在这里失踪了什么。
答案 0 :(得分:5)
试一试:
<ul>
<% if current_user.jobs.any? %>
<% current_user.jobs.each do |job| %>
<li> Job ID: <%= job.id %> Recipient: <%= job.recipient %> </li>
<% end %>
<% else %>
<%= "You have no jobs" %>
<% end %>
您正在打开each
并忘记关闭else