2016-04-24 4 views
-5

このコードを実行するたびに、エラーが発生しました。間違ったことが見つかりませんでした。シナティックエラーtidentifierについて、keyword_doまたは '{'または '('が必要です。それは何ができるかの?ruby​​ on rails識別子エラー1


_form.html.haml

= simple_form_for @pin, html: { multipart: true } do |f| 
    = if @pin.errors.any? 
    #errors 
    %h2 
    = pluralize(@pin.errors.count, "error") 
    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" 
+0

[HAMLのドキュメントから:](http://haml.info/docs/yardoc/)HAMLはHTML構造を表すために、個々の要素を持って__indentation__を使用しています。 –

+0

エラーメッセージは何ですか? –

答えて

1

コメントで指摘したとおり、HAMLはインデントに基づいてフォーマットする必要があります。あなたがしてあれば文を持っているのであればあなたの次の行はifから2ペイントでインデントされ、divや他のhtml要素の内容は親から2行インデントされています。あなたのコードでは、より多くのようになります。

= simple_form_for @pin, html: { multipart: true } do |f| 
    = if @pin.errors.any? 
    #errors 
     %h2 
     = pluralize(@pin.errors.count, "error") 
     prevented this pin from saving 
     %ul 
      - @pin.errors.full_messages.each do |msg| 
      %li = msg 

    .form-group 
    = f.input :move_in, input_html: { class: 'form-control' } 
    .form-group 
    = f.input :move_out, input_html: { class: 'form-control' } 
    = f.button :submit, class: "btn btn-primary" 
+0

オハイオ州オハイオ州は今それを得る@ありがとう –