2017-04-04 103 views
-1

任何人都可以看到为什么我会在我的代码中得到这个错误?HAML - “期待输入结束”Ruby错误

如果我删除错误捕获工作正常,但无法看到错误捕获问题。

感谢

= simple_form_for @pic, html: { multipart: true } do |f| 
     - if @pic.errors.any? 
     #errors 
      %h2 
      = pluralize(@pic.errors.count, "error") 
      prevented this Pic from saving 
      %ul 
       - @pic.errors.full_message.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-info" 
+0

仔细检查缩进和间距。 –

+0

你可以检查你的缩进,并确保它是一致的吗?欲了解更多信息[检查此](http://haml.info/docs/yardoc/#indentation)。还要确保你的缩进符合application.html.haml – alexunger

回答

0

您的代码缩进问题,试试这个

= simple_form_for @pic, html: { multipart: true } do |f| 
    - if @pic.errors.any? 
    #errors 
     %h2 
     = pluralize(@pic.errors.count, "error") 
     prevented this Pic from saving 
     %ul 
      - @pic.errors.full_message.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-info" 

希望帮助!

+1

干杯哥们:)工作过。我以为我有排序的缩进:)显然错过了一个或2个:D非常感谢 –

相关问题