gpt4 book ai didi

ruby-on-rails - 为什么我的 View 出现语法错误?

转载 作者:行者123 更新时间:2023-12-02 01:35:12 29 4
gpt4 key购买 nike

我正在尝试评估 3 条件以了解应呈现哪个按钮。代码是:

            <% if action == "edit" %>
<%= link_to '<button type="button" class="btn btn-warning"><i class="fa fa-reply"></i> Volver</button>'.html_safe, customers_path %>
&nbsp;
<%= button_tag(type: 'submit', class: "btn btn-success") do %>
<i class="fa fa-floppy-o"></i> Guardar
<% elsif action == "show" %>
<!--<%= link_to '<button type="button" class="btn btn-default"><i class="fa fa-pencil"></i> Editar</button>'.html_safe, edit_customer_path(@customer) %>-->
<% elsif action == "new" %>
<%= link_to '<button type="button" class="btn btn-warning"><i class="fa fa-reply"></i> Volver</button>'.html_safe, customers_path %>
&nbsp;
<%= button_tag(type: 'submit', class: "btn btn-success") do %>
<i class="fa fa-floppy-o"></i> Guardar
<% end %>

我收到以下错误:

/home/nando/gadmon/app/views/customers/_form.html.erb:62: syntax error, unexpected keyword_elsif, expecting keyword_end '.freeze; elsif action == "show" ^ /home/nando/gadmon/app/views/customers/_form.html.erb:64: syntax error, unexpected keyword_elsif, expecting keyword_end '.freeze; elsif action == "new" ^ /home/nando/gadmon/app/views/customers/_form.html.erb:76: syntax error, unexpected keyword_ensure, expecting keyword_end /home/nando/gadmon/app/views/customers/_form.html.erb:78: syntax error, unexpected end-of-input, expecting keyword_end

我试图在 if、elsif 或 else 之后添加“结束”标签,但仍然不起作用。

问候。

最佳答案

你所有的按钮都需要 <% end %>

<% if action == "edit" %>
<%= link_to '<button type="button" class="btn btn-warning"><i class="fa fa-reply"></i> Volver</button>'.html_safe, customers_path %>
&nbsp;
<%= button_tag(type: 'submit', class: "btn btn-success") do %>
<i class="fa fa-floppy-o"></i> Guardar
<% end %>
<% elsif action == "show" %>
<!--<%= link_to '<button type="button" class="btn btn-default"><i class="fa fa-pencil"></i> Editar</button>'.html_safe, edit_customer_path(@customer) %>-->
<% elsif action == "new" %>
<%= link_to '<button type="button" class="btn btn-warning"><i class="fa fa-reply"></i> Volver</button>'.html_safe, customers_path %>
&nbsp;
<%= button_tag(type: 'submit', class: "btn btn-success") do %>
<i class="fa fa-floppy-o"></i> Guardar
<% end %>
<% end %>

关于ruby-on-rails - 为什么我的 View 出现语法错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31665544/

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