2
votes
= 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

4

4 Answers

5
votes

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
1
votes

Can't really tell if the code indentations got messed up when you pasted in your code or that's how you actually have it, but yea, you have several mis-indentations. For example:

= simple_form_for @pin, html: { multipart: true} do |f|
- if @pin.errors

That - if should be indented over 2 spaces. so that it's in the scope of the simple form above it. Same goes for you ul and its lis within the each

0
votes

In my case, it worked when I remove the indentation between %ul and - @pin.errors.full_messages.each do |msg|. I still don't know the reason though since the - @pin.errors.full_messages.each do |msg| is supposed to be inside the @ul tag.

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

In my case, it was a single missed quote:

= link_to 'How to create an offer, '#', class: 'icu-card-title-link card-title'