任何人都可以看到为什么我的代码会出现此错误?
如果我删除错误陷阱它工作正常但无法看到错误捕获的问题。
感谢
= simple_form_for @pic, html: { multipart: true } do |f|
- if @pic.errors.any?
#errors
%h2
= pluralize(@pic.errors.count, "error")
prevented this Pic from saving
%ul
- @pic.errors.full_message.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-info"
答案 0 :(得分:0)
您的代码存在缩进问题,请尝试此操作
= simple_form_for @pic, html: { multipart: true } do |f|
- if @pic.errors.any?
#errors
%h2
= pluralize(@pic.errors.count, "error")
prevented this Pic from saving
%ul
- @pic.errors.full_message.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-info"
希望有所帮助!