2016-04-24 9 views
-5

Jedes Mal, wenn ich diesen Code ausführen, bekomme ich einen Fehler kann nicht finden, was ich falsch getan hatte, sagte etwas über synatic error tidentifier, erwartet Keyword_do oder '{' oder '('. Jeder hat einen Vorschlag auf das, was es sein könnte?Ruby auf Schienen Identifier Fehler 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

[Von der HAML Dokumentation:] (http://haml.info/docs/yardoc/) Haml verwendet __indentation__ die einzelnen Elemente zu bringen, die HTML-Struktur darzustellen. –

+0

Was ist die Fehlermeldung? –

Antwort

1

Wie in den Kommentaren darauf hingewiesen, hat HAML basierend auf Einzug formatiert werden. wenn Sie also ein und if-Anweisung dann haben Die nächste Zeile sollte um 2 Schritte vom if und vom Inhalt eines div oder eines anderen html-Elements eingerückt werden eingerückt 2 Zeilen von ihren Eltern. Der Code sollte aussehen wie:

= 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

oh ok danke, jetzt bekomme ich es @trh –