Topic: Incorrect parameter type in fields_for (Rails 4 b1).
I've got 3 models that are nested: User has_one :profile, a Profile has_many :contact_addresses.
(In both User and Profile, I have accepts_nested_attributes_for 'child model')
In the user form, I have something like:
<%= form_for @user do |user_form| %> <%= user_form.text_field :username %> <%= user_form.fields_for @user.profile do |profile_form| %> <%= profile_form.fields_for @user.profile.contact_addresses do |contact_field_form| %> <%= contact_field_form.text_field :address %> <% end %> <% end %> <%= user_form.submit %> <% end %>
The form renders properly and I see the attributes I'd expect. However, when I submit the form I get:
Profile expected, got ActionController::Parameters
The private method to get my params looks like:
def user_params params.require(:user).permit(:username, profile: [:contact_field_attributes]) end
The parameters are being passed through to the controller action from user_params, but the class is incorrect.
I'm also not sure why the contact_fields models are in a parameter called inventory_items_attributes and the profile isn't in profile_attributes (perhaps because that is a has_one assoc.?)
Any help would be much appreciated! Thanks.