。意外的kELSIF错误?

时间:2015-07-29 21:04:38

标签: ruby-on-rails

我收到了“。意外的kELSIF”错误。我真的不确定它在抱怨什么。我正在运行anested if else循环来检查没有公司或没有子公司的值。我以前从未见过这个错误。它只会在第二个elsif语句上抛出错误。这是我的代码:

      <tr>
        <% prime = w.positions.joins(:company, :hire_type).where(:hire_types => { :hire_type => "Prime" }).pluck('companies.company_name').uniq %>
        <% sub = w.positions.joins(:company, :hire_type).where(:hire_types => { :hire_type => "Sub" }).pluck('companies.company_name').uniq %>
        <% if ((prime.length == 0) && (sub.length == 0))%>
          <td class="tg-celltitle">Prime: </td>
          <td class="tg-datacell"></td>
          <td class="tg-celltitle">Subcontractor: </td>
          <td class="tg-datacell"></td>

        <% elsif ((prime.length == 0) && (sub.length != 0)) %>
          <td class="tg-celltitle">Prime: </td>
          <td class="tg-datacell"></td>
          <% sub.each do |s| %>
            <% if s == sub.first %>
              <td class="tg-celltitle" rowspan="<%= sub.length %>">Subcontractor: </td>
            <% end %>
            <td class="tg-datacell"><%= s %></td>



        <% elsif ((prime.length != 0) && (sub.length == 0))%>
          <% prime.each do |p| %>
            <% if p == prime.first %>
              <td class="tg-celltitle" rowspan="<%= prime.length %>">Prime: </td>
            <% end %>
          <td class="tg-datacell"><%= p %></td>
          <td class="tg-celltitle" rowspan="<%= prime.length %>">Subcontractor: </td>
          <td class="tg-datacell" rowspan="<%= prime.length %>"></td>


        <% elsif ((prime.length != 0) && (sub.length != 0))  %>
          <% prime.each do |p| %>
            <% if p == prime.first %>
              <td class="tg-celltitle" rowspan="<%= prime.length %>">Prime: </td>
            <% end %>
            <td class="tg-datacell"><%= p %></td>
          <% sub.each do |s| %>
            <% if s == sub.first %>
              <td class="tg-celltitle" rowspan="<%= sub.length %>">Subcontractor: </td>
            <% end %>
            <td class="tg-datacell"><%= s %></td>

          </tr>
        <% end %>
      <% end %>

2 个答案:

答案 0 :(得分:0)

您忘记了第一个Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE); intent.setType("message/rfc822"); intent.putExtra(Intent.EXTRA_SUBJECT, "My subject"); intent.putExtra(Intent.EXTRA_TEXT, "My text"); startActivity(intent);

中的右括号
elsif

----------更新--------------------

您需要使用<% elsif ((prime.length == 0) && (sub.length != 0)) %>

关闭.each块

关闭后的完整摘录:

<%end%>

答案 1 :(得分:0)

<% sub.each do |s| %>

对于每个声明,您没有块的结束语句。

相反,它会遇到elsif,这就是错误的原因。