缺少部分错误与使用 simple_form & cocoon 时未显示的按钮

Missing partial error vs button not showing while using simple_form & cocoon

我是 rails 的新手,我正在尝试结合使用 cocoon 和 simple_form 为我正在关注的菜谱应用程序教程创建一些嵌套表单。他们使用 haml,当我似乎遵循了 haml 的正确缩进过程时,我得到了一个丢失的部分错误。

错误信息:

Missing partial recipes/_ingredient_fields, application/_ingredient_fields with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :haml, :jbuilder]}.

.row
            .col-md-6
                %h3 Ingredients
                #ingredients
                    = f.simple_fields_for :ingredients do |ingredient|
                        = render 'ingredients_fields', f: ingredient
                    .links #line below is the error line
                      = link_to_add_association 'Add Ingredient', f, :ingredients, class: 'btn btn-default add-button'

    = f.button :submit, class: 'btn btn-primary'

如果我在 .linkslink_to_add_association 行上切换,将显示视图,但不会显示 ingredient 按钮和文本区域。我正在按照 cocoon 文档 (https://github.com/nathanvda/cocoon) 中所述的程序进行操作,但我似乎无法让它工作。以下是每个文件的完整代码。请告诉我是否需要包含任何其他文件。在此先感谢您的帮助!

_form.html.haml

= simple_form_for @recipe, html: { multipart: true } do |f|
    - if @recipe.errors.any?
        #errors
            %p
                = @recipe.errors.count
                Prevented this recipe from saving.
            %ul
                - @recipe.errors.full_messages.each do |msg|
                    %li= msg
    .panel-body
        = f.input :title, input_html: { class: 'form-control' }
        = f.input :description, input_html: { class: 'form-control' }
        = f.input :image, input_html: { class: 'form-control' }

        .row
            .col-md-6
                %h3 Ingredients
                #ingredients
                    = f.simple_fields_for :ingredients do |ingredient|
                        = render 'ingredients_fields', f: ingredient
                    .links
                        = link_to_add_association 'Add Ingredient', f, :ingredients, class: 'btn btn-default add-button'

    = f.button :submit, class: 'btn btn-primary'

_ingredients_fields.html.haml

.form-inline.clearfix
    .nested-fields
        = f.input :name, input_html: { class: 'form-input form-control' }
        = link_to_remove_association "Remove", f, class: 'form-button btn btn-default'

您的文件名为 _ingredients_fields,需要 _ingredient_fields(单一成分)