gpt4 book ai didi

ruby-on-rails - Rails 语法错误 : unexpected keyword_ensure, 需要 keyword_end

转载 作者:数据小太阳 更新时间:2023-10-29 07:21:42 24 4
gpt4 key购买 nike

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

以上代码似乎导致:

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

这是怎么回事?这个语法有什么问题?

最佳答案

您收到的错误很可能源于尝试执行 if-else 条件,其中您有一个额外的 <% end %> 之前 <% else %> .确保您的条件遵循规范的 if-else-end 逻辑,如下所示:

<% if ... %>
<% @ballot_link = "/vote/#{params[:election_id]}/ballot/#{params[:ballot_position]}" %>
<a href="<%= @ballot_link %>" class="btn btn-primary">Ready</a>
<% else %>
...
<% end %>

关于ruby-on-rails - Rails 语法错误 : unexpected keyword_ensure, 需要 keyword_end,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17715290/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com