2017-02-13 34 views
-4

enter image description here紅寶石HAML意外結束錯誤的

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

我不認爲你會得到太多的幫助,除非你花1幾秒鐘正確格式化你的發帖,並2.提出一個問題。 –

回答

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"