_form代码是:
= simple_form_for @book, html: { multipart: true } do |f|
- if @book.errors.any?
#errors
%p
= @book.errors.count
Prevented this book from saving
%ul
- @book.errors.full_message.each do |msg|
%li= msg
.panel-body
=f.input :title, input_html: {class: 'form-control'}
=f.input :description, input_html: {class: 'form-control'}
=f.button :submit, class: "btn btn-primary"
答案 0 :(得分:2)
HAML嵌套由空格决定。您需要插入一些,以便HAML解释器知道嵌套的范围。例如,form
中的所有内容都必须显示比form
行更多的前一个空格
= simple_form_for @book, html: { multipart: true } do |f|
- if @book.errors.any?
#errors
%p
= @book.errors.count
Prevented this book from saving
%ul
- @book.errors.full_message.each do |msg|
%li= msg
.panel-body
=f.input :title, input_html: {class: 'form-control'}
=f.input :description, input_html: {class: 'form-control'}
=f.button :submit, class: "btn btn-primary"