当我运行show#错误时发现空间错误如果我删除#error行则显示show #p错误更深层的错误

时间:2018-08-31 16:06:20

标签: ruby-on-rails haml

Haml::SyntaxError in Recipes#new
Showing /home/shoaib/Documents/Projects/recipe_box/app/views/recipes/_form.html.haml where line #4 raised:

The line was indented 4 levels deeper than the previous line.
Extracted source (around line #4):
2
3
4
5
6
7

 - if @recipe.errors.any?
 #errors
     %p
       = @recipe.errors.count
       Prevented this recipe froms saving
     %ul

1 个答案:

答案 0 :(得分:0)

#errors之前添加两个空格。 Haml缩进是它的基础,它定义了它的代码块,而不是使用结束线,因此您必须尊重它,并且只应使用空格(不使用制表符),并且始终使用相同的数量(常规为2个空格)。