2014-12-07 67 views
0

我在軌道下面的表格,其HAML:簡單的形式在另一個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 
       [email protected] do |msg| 
        %li= msg 
     .panel-body 
      =f.input :title, input_html: {class: 'form-control'} 
      =f.input :desciption, input_html: { class: 'form-control'} 

     f.button :submit, class: "btn btn-primary" 

我試圖顯示這個表單到另一個文件new.html.haml:

%h1 New Recipe 

= render 'form' 

%br/ 

= link_to "Back", root_path, class: "btn btn-default" 

但形式上沒有出現,我可以看到標題新配方和後退按鈕,但沒有形成

任何線索?

感謝

回答

1

看來一切- if @recipe.errors.any?下嵌套。 請嘗試取消縮進.panel-bodyf.button(應該是= f.button),以便它們符合if

+0

謝謝你,讓它工作。感謝你的幫助 – 2014-12-07 23:28:22