2017-02-13 10 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" 
関連する問題