ruby-on-railsactionviewfields-for

Generate correct name with fields_for in Rails


= 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?


Solution

  • What I needed was:

    = f.fields_for :account, @user.account || @user.build_account do |account|