簡體   English   中英

haml和Rails RailsGuides入門

[英]haml and Getting Started with Rails RailsGuides

無法弄清楚為什么我的標簽沒有以“新建”和“編輯”視圖中使用的形式顯示。 我只能看到%h2標簽。 之后聲明的部分不生成。

這就是我所擁有的。 我想念什么? (_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

表格位於app / views / tags _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

或者,如果不在這里。 我還應該看哪里?

謝謝!

根據您使用的Rails版本,您需要進行許多更改:

= form.fields_for :tags do |tag_form|

- form.fields_for :tags do |tag_form|

也許你應該縮進

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

右邊還有兩個空格,以便它位於表單內部

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM