I have two models, User and Profile, that have a one-to-one
relationship and which I am creating in the same form. I thought I’d
give nested object forms a go, but got stuck with two problems:
-
When I use the syntax from the tutorials I found,
‘form.fields_for :profile do |profile_form|’, then the key of the
resulting params hash is ‘profile’, and the User model seems to expect
‘profile_attributes’ instead. So I had to change the syntax to
‘form.fields_for :profile_attributes do |profile_form|’. Is this the
way to go? -
What is the best way to get the form fields to be pre-filled with
existing profile attributes when the form comes back with validation
errors? Shouldn’t that happen automatically? Maybe the fact that it
isn’t is related to 1) somehow?
Thanks for any hint!
ingo