我想在窗體中使用多個嵌套的屬性,雖然只有第一組屬性似乎出現。軌道項目上的紅寶石內的多個嵌套窗體
下面是HAML模板
.mdl-cell.mdl-cell--10-col.mdl-cell--1-offset
%h3.mdl-typography--display-1= t('.account_title')
= form.fields_for :address do |address_fields|
.mdl-grid
.mdl-textfield.mdl-js-textfield.mdl-textfield--floating-label.mdl-cell.mdl-cell--6-col
= address_fields.text_field :first_name, class: 'mdl-textfield__input'
= address_fields.label :first_name, class: 'mdl-textfield__label'
.mdl-textfield.mdl-js-textfield.mdl-textfield--floating-label.mdl-cell.mdl-cell--6-col
= address_fields.text_field :last_name, class: 'mdl-textfield__input'
= address_fields.label :last_name, class: 'mdl-textfield__label'
.mdl-textfield.mdl-js-textfield.mdl-textfield--floating-label.mdl-cell.mdl-cell--6-col
= form.text_field :name, class: 'mdl-textfield__input'
= form.label :name, class: 'mdl-textfield__label'
.mdl-textfield.mdl-js-textfield.mdl-textfield--floating-label.mdl-cell.mdl-cell--6-col
= form.email_field :email, class: 'mdl-textfield__input'
= form.label :email, class: 'mdl-textfield__label'
%h3.mdl-typography--display-1= t('.bank_title')
= form.fields_for :account do |account_fields|
.mdl-grid
.mdl-textfield.mdl-js-textfield.mdl-textfield--floating-label.mdl-cell.mdl-cell--6-col
= account_fields.text_field :bsb, class: 'mdl-textfield__input'
= account_fields.label :bsb, class: 'mdl-textfield__label'
.mdl-textfield.mdl-js-textfield.mdl-textfield--floating-label.mdl-cell.mdl-cell--6-col
= account_fields.text_field :account_number, class: 'mdl-textfield__input'
= account_fields.label :account_number, class: 'mdl-textfield__label'
.mdl-textfield.mdl-js-textfield.mdl-textfield--floating-label.mdl-cell.mdl-cell--12-col
= account_fields.text_field :account_name, class: 'mdl-textfield__input'
= account_fields.label :account_name, class: 'mdl-textfield__label'
定義在型號
accepts_nested_attributes_for :address, reject_if: proc { |attributes| attributes['address1'].blank? }
accepts_nested_attributes_for :trading_hours
accepts_nested_attributes_for :phones, :reject_if => lambda { |t| (t['display_number'].gsub(/\D+/, '').blank?) }
accepts_nested_attributes_for :account
你能顯示從你的rails服務器日誌傳遞的參數嗎? – Kumar