index.html.hamlRails的嵌套在索引頁的形式顯示的字段與父窗體
我有一個客戶的細節形成有一個名爲「商品地址」的嵌套形式一起。我想在索引頁面中顯示所有客戶詳細信息。
%tbody
- @customer_details.each do |customer|
%tr
%td= customer.customer_name
%td= customer.customer_id
%td= customer.address
%td= customer.state
%td= customer.email
嵌套形式
= fields_for customer_detail do |f|
= f.fields_for :goods_address do |t|
.fieldset
.row
.col-sm-12
= t.label :delivery_address,"Goods to be delivered at same address mention above?", class: "col-sm-6 control-label text-right"
= t.check_box :delivery_address, autofocus: true, class: "toggle-two customer-goods col-sm-6", :value => "On"
%br
%div{id: 'customer_goods'}
.main-center-pan.main-login-pan
.fieldset
.row
.col-sm-12
= t.label :name,"Name", class: "col-sm-3 control-label text-right"
= t.text_field :name, autofocus: true, class: "col-sm-3"
= t.label :contact_no,"Contact number", class: "col-sm-3 control-label text-right"
= t.text_field :contact_no, autofocus: true, class: "col-sm-3"
%br
母體形式
= nested_form_for(@customer_detail) do |f|
- all_views_side_error_messages!(@customer_detail)
.form-alignment
.fieldset
.row
.col-sm-12
= f.label :customer_name,"Organisation/Customer Name", class: "col-sm-3 control-label text-right"
= f.text_field :customer_name, autofocus: true, class: "col-sm-3"
= f.label :residential_type,"Residential Type", class: "col-sm-3 control-label text-right"
= f.check_box :residential_type, autofocus: true, "data-width" => "200", class: "toggle-two-resident select-resident col-sm-3"
%br
問題是我不知道如何定義嵌套表單的字段在index.can有人plz幫助我。提前感謝。
如果我理解正確,你想在父控制器的索引操作上顯示孩子的屬性,對吧? –
yes.u是對的 –