gpt4 book ai didi

ruby-on-rails - Ruby haml 意外结束错误

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

= simple_form_for @pin, html: { multipart: true} do |f|
- if @pin.errors.any?
#errors
%h2
= pluralize(@pin.errors.count, "errors")
prevented this Pin from saving
%ul
- @pin.errors.full_messages.each do |msg|
%li= msg
.form-group
= f.input :title, input_html: { class: 'form-control' }

.form-group
= f.input :description, input_html:{ class: 'form-control' }

= f.button :submit, class: "btn btn-primary"

有人能告诉我为什么这会返回下面针对 rails 的错误

/Users/frankchen/project/pin_board/app/views/pins/_form.html.haml:17: syntax error, unexpected keyword_ensure, expecting keyword_end ...:Util.html_safe(_erbout);ensure;@haml_buffer = @haml_buffer.... ... ^ /Users/frankchen/project/pin_board/app/views/pins/_form.html.haml:20: syntax error, unexpected end-of-input, expecting keyword_end

最佳答案

如果是 HAML,则很可能是缩进问题。我无法匹配您提供的行号,因为我们只看到了代码片段,但我猜测这两行之间的缩进已关闭:

- @pin.errors.full_messages.each do |msg|
%li= msg

关于ruby-on-rails - Ruby haml 意外结束错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30040861/

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