Rails如何直3行条件?

Rails how to straight 3 row conditional?

我收到以下语法错误,我不明白为什么:

syntax error, unexpected keyword_ensure, expecting keyword_end

如果未使用选项 1 或 2,我试图将用户引导至选项 3,所以我这样做了:

<%if order.dispute.status == "open" %>

  <li>
    <%= button_to 'Dispute Open',  order_dispute_path(order), method: :get, class: 'btn_grey' %>
  </li>

<% elsif %>

  <li>
    <%= button_to 'Dispute',  new_order_dispute_path(order), method: :get, class: 'btn_grey' %>
  </li>

<% else %>

  <li>
    <%= button_to 'Dispute closed',  closed_order_dispute_path, method: :get, class: 'btn_grey' %>
  </li>

<% end %>

你不能自己写<% elsif %>

Else if what??

您写的内容与以下一样有意义:

if
  puts "this"
else
  puts "that"
end

(当然这也是非法语法。)

我猜你想写这样的东西:

<% elsif order.dispute.nil? %>