2011-11-07 51 views
0

无法弄清楚为什么我的标签没有显示在New和Edit视图中使用的表单中。我只能看到%h2标签。之后声明的部分根本不生成。haml和Rails入门RailsGuides

这是我的。我错过了什么? (_form.html.haml)

=form_for @post do |form| 
. 
. 
. 
%p 
    =form.label :content 
    %br 
    =form.text_area :content 

%h2 
    Tags 
= render :partial => 'tags/form', :locals => {:form => form} 

%p 
    =form.submit 

形式位于应用程序/视图/标签 _form.html.haml。 这一切都没有出现:

= form.fields_for :tags do |tag_form| 
    .field 
    = tag_form.label :name, 'Tag:' 
    = tag_form.text_field :name 
    - unless tag_form.object.nil? || tag_form.object.new_record? 
    .field 
     = tag_form.label :_destroy, 'Remove:' 
     = tag_form.check_box :_destroy 

或者如果它不在这里。我应该在哪里看?

谢谢!

+1

当你说“app/views/tags/_form.html.haml”时,你的意思是“app/views/tags/_form.html.haml”正确吗? –

回答

1

根据您使用Rails的版本,你很多需要改变:

= form.fields_for :tags do |tag_form| 

- form.fields_for :tags do |tag_form| 
0

或者也许你应该缩进

=渲染:部分= >'tags/form',:locals => {:form => form}

向右多了两个空格,以便它在表格内