What I needed was:
= f.fields_for :account, @user.account || @user.build_account do |account|
Вопрос
= f.field_for @user.account || @user.build_account do |account|
= account.text_field :name
Is generating
<input name="user[account][name]">
and I want:
<input name="user[account_attributes][name]">
what am I doing wrong?
Решение
What I needed was:
= f.fields_for :account, @user.account || @user.build_account do |account|
Другие советы
Passing by, I would like to mention the object_name
method
account.object_name
should return "user[account_attributes]"
So if you concatenate your field name between brackets "[field_name]"
, you can easily construct the right name for your input's field