Search code examples
ruby-on-railsrubyhamlsimple-form

Ruby haml unexpected ending error


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

can someone tell me why this is returing me the error that says below for rails

/Users/frankchen/project/pin_board/app/views/pins/_form.html.haml:17: syntax error, unexpected keyword_ensure, expecting keyword_end ...:Util.html_safe(_erbout);ensure;@haml_buffer = @haml_buffer.... ... ^ /Users/frankchen/project/pin_board/app/views/pins/_form.html.haml:20: syntax error, unexpected end-of-input, expecting keyword_end


Solution

  • If it's HAML, it's more than likely an indentation issue. I can't match up the line number you provided since we're only seeing a snippet of the code, but I'm guessing that the indentation between these two lines is off:

    - @pin.errors.full_messages.each do |msg|
    %li= msg