문제

I am learning rails and I get a syntax error unexpected keyword else, expected keyword end on the following code and I don t know why.

<% if @quo.pro_con.nil? do %>
  <div class="procon">
    <%= f.label :pro_con %><br>
    <%= f.check_box :pro_con %>
  </div>
  <div class="comment">
    <%= f.label :comment %><br>
    <%= f.text_area :comment %>
  </div>
<% else %> 
  <p>
    <strong>Pro Con:</strong>
    <%= @quo.pro_con %>
  </p>
  <p>
    <strong>Comment:</strong>
    <%= @quo.comment %>
  </p>
<% end %> 

Why am I receiving the error, unexpected keyword else, expected keyword end?

도움이 되었습니까?

해결책

if does not require do clause. The interpreter sees do and awaits end to match. Change your first line to:

<% if @quo.pro_con.nil? %>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top