Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails syntax error: unexpected keyword_ensure, expecting keyword_end

<h1>Get Ready</h1>
<% if params[:ballot_position].to_i > 1 %>
<p>
Voter <%= params[:ballot_position].to_i - 1 %>, go get voter <%= params[:ballot_position] %>
and switch places with them.
</p>
<p>
Voter <%= params[:ballot_position] %>, when you are ready, click the button marked "Ready" below.
</p>
<% @ballot_link = "/vote/#{params[:election_id]}/ballot/#{params[:ballot_position]}" %>
<a href="<%= @ballot_link %>" class="btn btn-primary">Ready</a>

Above code seems to be resulting in:

ready.html.erb:13: syntax error, unexpected keyword_ensure, expecting keyword_end
ready.html.erb:15: syntax error, unexpected $end, expecting keyword_end

What's going on? What's wrong with this syntax?

like image 689
Muhd Avatar asked Dec 08 '22 14:12

Muhd


1 Answers

The errors you're receiving more than likely stem from trying to execute a if-else conditional wherein you have an extra <% end %> before <% else %>. Ensure that your conditional follows canonical if-else-end logic like the following:

<% if ... %>
    <% @ballot_link = "/vote/#{params[:election_id]}/ballot/#{params[:ballot_position]}" %>
    <a href="<%= @ballot_link %>" class="btn btn-primary">Ready</a>
<% else %>
    ...
<% end %>
like image 132
zeantsoi Avatar answered Dec 11 '22 08:12

zeantsoi