语法错误,意外的keyword_else,期待keyword_end&#39 ;;否则^

时间:2014-05-26 23:02:40

标签: ruby-on-rails view syntax

作业#新

<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 %>

不确定我在这里失踪了什么。

1 个答案:

答案 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